...

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



wallport10
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!


Thanks,
-Nate

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

SELECT * FROM table WHERE first_name LIKE A

Fumigator
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.

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

-Nate



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum