[thelist] PHP and Databases: Data retrieval in different sort order.

Atul Paul atul79 at rogers.com
Wed Jan 22 17:12:00 CST 2003


I have a table in MySql called Clients which has a unique (and primary)
field called, id. The table is sorted by this 'id'.

Now I wanna be able to search thru this table by 'Firstname' and
'Lastname'. Thats no problem. Here's my question. Lets say I search for
'John Doe'. Now the script will search and display the record. I also want
'previous' and 'next' buttons that will allow the user to traverse through
the database. But this traversal should be alphabetical by 'Lastname'. For
I have the following records in the table:
id firstname lastname
1 Carl Smith
2 John Doe
3 Able Jones
4 John Blah
5 Bill Johnson

Now if I search for John Doe it gives me that row. When I click on
'previous' it should take me to the previous record in the alphabetical
list, i.e. John Blah. In short, I wanna be able to let users traverse the
records in the following order of Lastname:

I am stumped. Please help
Thanks in advance.

My Blog: http://blog.verticalinsanity.com

More information about the thelist mailing list