Re: Looking for code for an alphabetic menu in php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2009/5/22 James Crow <james@xxxxxxxxxxxxx>:
> 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!"

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux