View Full Version : Pulling data from database based on first letter

08-22-2006, 06:35 PM
I've researched this and tried to code it myself but I havent had any luck. I want to pull data off a database, IE: first name, etc , based on the first letter. So I would have something like A B C and if you click on those letters they will bring up all the names or whatever field that start with that letter. Please help, I've spent countless hours trying to figure this out!


08-22-2006, 06:50 PM
wallport10 are you using Mysql? have you tried

SELECT * FROM table WHERE first_name LIKE A

08-22-2006, 06:50 PM
Use the "like" keyword along with the "%" wildcard:

$query = "SELECT * from yourtable where lastname like 'A%'";

You would of course want to replace that "A" with the value the user clicks on.

08-22-2006, 07:12 PM
Awsome, Thanks alot!