php-windows Digest 23 May 2009 09:00:33 -0000 Issue 3628

Topics (messages 29344 through 29349):

Re: Looking for code for an alphabetic menu in php
        29344 by: Lester Caine
        29345 by: Sascha Meyer
        29346 by: James Crow
        29347 by: Richard Quadling
        29348 by: Joseph LeBlanc

vbscript not running in php but running as a vbs file
        29349 by: Rui

Administrivia:

To subscribe to the digest, e-mail:
        php-windows-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-windows-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-wind...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Bill Mudry wrote:
With the botanical wood tree that I have been working on, the number of records for genera and for species can get quite large and unwieldy. Presently I have over 6,000
species records that takes a while to load let alone try to browse through.

I need to chop this up into querying by alphabet of the first letter of the species botanical names. For the species level of organization, I have been keeping the data in a MySQL file called simply 'species'. I want to have a single character of the alphabet with each acting as a link for the first character of each species name:
        A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
When a user click on one of them, it should be readable (eg. using $_GET??) into a common variable for them all that can then be used for a select statement. The rest of displaying the
results in columns I already have working fine.

What suggestions do you have for typical code that should work?

Not quite sure what your problem is, you just need to add a filter to the where clause of your query. I don't think MySQL has STARTING 'A', but it certainly has LIKE 'A%', so just get each letter to return a link containing it's letter and use that to select the 'page' of names you want.

$a = $_GET['letter'];
$sql = "SELECT * FROM SPECIES WHERE NAME LIKE '$a%'";

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--- End Message ---
--- Begin Message ---
Hi Bill,

I don't know if I got you right but I hope this will help:

[CODE]
<?php
$baseLink = "index.php?letter="; // Assuming your file name is "index.php"; set up the base link for all pages

//alphabetical links
for($a=65;$a<(65+26);$a++){
   print "<a href=\"".$baseLink.chr($a)."\">".chr($a)."</a>\n";
}
if (isset($_GET["letter"]) && $_GET["letter"] != ""){
   $letter = $_GET["letter"];
$sql = "SELECT * FROM species WHERE [SPECIES_NAME] LIKE '".$letter."%'"; // Replace [SPECIES_NAME] with your column name
   $res = mysql_query($sql);
   if ($res){
       while ($row = mysql_fetch_row($res)){
           // retrieve your row info
       }
   } else {
       print "Failed retrieving data set, error was: ".mysql_error();
   }
}
?>
[/CODE]

Enjoy,

Sascha


Bill Mudry schrieb:
With the botanical wood tree that I have been working on, the number of records for genera and for species can get quite large and unwieldy. Presently I have over 6,000 species records that takes a while to load let alone try to browse through.

I need to chop this up into querying by alphabet of the first letter of the species botanical names. For the species level of organization, I have been keeping the data in a MySQL file called simply 'species'. I want to have a single character of the alphabet with each acting as a link for the first character of each species name:
        A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
When a user click on one of them, it should be readable (eg. using $_GET??) into a common variable for them all that can then be used for a select statement. The rest of displaying the
results in columns I already have working fine.

What suggestions do you have for typical code that should work?

Much thanks in advance,

Bill Mudry
Mississauga, Ontario, Canada


--- End Message ---
--- Begin Message ---
Bill Mudry wrote:
With the botanical wood tree that I have been working on, the number of records for genera and for species can get quite large and unwieldy. Presently I have over 6,000 species records that takes a while to load let alone try to browse through.

I need to chop this up into querying by alphabet of the first letter of the species botanical names. For the species level of organization, I have been keeping the data in a MySQL file called simply 'species'. I want to have a single character of the alphabet with each acting as a link for the first character of each species name:
        A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
When a user click on one of them, it should be readable (eg. using $_GET??) into a common variable for them all that can then be used for a select statement. The rest of displaying the
results in columns I already have working fine.

What suggestions do you have for typical code that should work?

Much thanks in advance,

Bill Mudry
Mississauga, Ontario, Canada
Bill,

I read this as you want the user to be able to select multiple letters to search on. If so I would recommend making each letter a checkbox. In your php code you would need to check each element in the $_GET or $_POST array. The SQL would then need to be:

SELECT species_name
   FROM species
   WHERE species_name LIKE 'b%'
   OR species_name LIKE 'g%'
   OR species_name LIKE 'r%';

Replace species_name with the correct column name.

Without resorting to some sort of client side scripting I am not sure you could select multiple letters to search on with simple HTML links.

Cheers,
James


--- End Message ---
--- Begin Message ---
2009/5/22 James Crow <ja...@ultratans.com>:
> Bill Mudry wrote:
>>
>> With the botanical wood tree that I have been working on, the number of
>> records for
>> genera and for species can get quite large and unwieldy. Presently I have
>> over 6,000
>> species records that takes a while to load let alone try to browse
>> through.
>>
>> I need to chop this up into querying by alphabet of the first letter of
>> the species
>> botanical names. For the species level of organization, I have been
>> keeping the
>> data in a MySQL file called simply 'species'. I want to have a single
>> character of the
>> alphabet with each acting as a link for the first character of each
>> species name:
>>        A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
>> When a user click on one of them, it should be readable (eg. using
>> $_GET??) into a common variable for
>> them all that can then be used for a select statement. The rest of
>> displaying the
>> results in columns I already have working fine.
>>
>> What suggestions do you have for typical code that should work?
>>
>> Much thanks in advance,
>>
>> Bill Mudry
>> Mississauga, Ontario, Canada
>
> Bill,
>
>  I read this as you want the user to be able to select multiple letters to
> search on. If so I would recommend making each letter a checkbox. In your
> php code you would need to check each element in the $_GET or $_POST array.
> The SQL would then need to be:
>
> SELECT species_name
>   FROM species
>   WHERE species_name LIKE 'b%'
>   OR species_name LIKE 'g%'
>   OR species_name LIKE 'r%';
>
> Replace species_name with the correct column name.
>
> Without resorting to some sort of client side scripting I am not sure you
> could select multiple letters to search on with simple HTML links.
>
> Cheers,
> James
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

You can also ...

SELECT species_name
  FROM species
  WHERE species_name LIKE '[bgr]%'

Slightly smaller code.

-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

--- End Message ---
--- Begin Message --- Make sure you filter $letter before using it in the query. Replace $letter = $_GET["letter"] with this:

preg_match('/^[A-Z]/', $_GET["letter"], $matches);
$letter = $matches[0];

If you don't do this, someone could insert malicious SQL into the $letter variable. This regular expression will match only one capital letter at the beginning of the string $_GET["letter"].

-Joe

On May 22, 2009, at 3:23 AM, Sascha Meyer wrote:

Hi Bill,

I don't know if I got you right but I hope this will help:

[CODE]
<?php
$baseLink = "index.php?letter="; // Assuming your file name is "index.php"; set up the base link for all pages

//alphabetical links
for($a=65;$a<(65+26);$a++){
  print "<a href=\"".$baseLink.chr($a)."\">".chr($a)."</a>\n";
}
if (isset($_GET["letter"]) && $_GET["letter"] != ""){
  $letter = $_GET["letter"];
$sql = "SELECT * FROM species WHERE [SPECIES_NAME] LIKE '". $letter."%'"; // Replace [SPECIES_NAME] with your column name
  $res = mysql_query($sql);
  if ($res){
      while ($row = mysql_fetch_row($res)){
          // retrieve your row info
      }
  } else {
      print "Failed retrieving data set, error was: ".mysql_error();
  }
}
?>
[/CODE]

Enjoy,

Sascha


--- End Message ---
--- Begin Message ---
hi
im having a problem with a vbscript that sends mail .

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "mysubject"
objMessage.From = "mymail"
objMessage.To = "destinator"
objMessage.TextBody = "mytextbody"
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing";) = 2 objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver";) = "mysmtp" objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport";) = 25
objMessage.Configuration.Fields.Update
objMessage.Send

if i run this like a vbs file it runs like a charm . i receive the mail no problem .

if i add this to a php page with the tags
<SCRIPT LANGUAGE="VBScript">
......
</SCRIPT>

it does not work . it does not give any error .....and if i check smtp server log it does not even get to the server .
it looks either it does not process or it doesnt leave the workstation.

any ideias ?

thks in advance

rgds
rui
--- End Message ---

Reply via email to