Re: Looking for code for an alphabetic menu in php
Lester Caine <[email protected]>
| Newsgroups | gmane.comp.php.windows |
|---|---|
| Message-ID | <[email protected]> |
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 -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php