TecTao Posted January 23, 2007 Share Posted January 23, 2007 I am using a last name query for a list of members in a DB.I'm a bit confused on stripping the letters down and then out to the first letter of the name such as,Smith down to "S" or Brown down to "B" so that the query for the letter "S" or "B" returns the names starting with those e letters.Thanks for any help in advance.Mike Quote Link to comment Share on other sites More sharing options...
fert Posted January 23, 2007 Share Posted January 23, 2007 [code]$letter=$name{0};[/code] Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 23, 2007 Share Posted January 23, 2007 Once you have the first letter, then do"SELECT * FROM table WHERE name LIKE '$letter%' Quote Link to comment Share on other sites More sharing options...
subbukumararaja Posted January 23, 2007 Share Posted January 23, 2007 $lastName = "George"now $lastName[0] will return the first letter of the nameso,[b]select * from table_name where last_name like "$lastName[0]%"[/b]is this the one that u have asked? Quote Link to comment Share on other sites More sharing options...
TecTao Posted January 23, 2007 Author Share Posted January 23, 2007 Thanks all. The post from Jerirose worked perfectly since I was passing a letter veriable from a previous page.Thanks for all the help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.