jwk811 Posted December 17, 2006 Share Posted December 17, 2006 i have a list of words and they will be categorized by the first letter.. like the person will click a or b or c etc. and all the words with that letter will come up.. for the first part i will need to know how to be able to see what the first letter of the word is so i can do that.. next i will need to figure out how i can take only the words starting with that letter from the database to be displayed.. i need help with both but either will be great! thanks for any help on this! Quote Link to comment Share on other sites More sharing options...
mlin Posted December 17, 2006 Share Posted December 17, 2006 Well you can always get the 1st letter of a string just like you'd get the 1st element of an array:$a = "string";echo $a[0];that would output sbut to search for all records that start with a particular letter you could use a like in your query:select * from table_name where column like 'a%'that should get all the records from column that start with a Quote Link to comment Share on other sites More sharing options...
doni49 Posted December 17, 2006 Share Posted December 17, 2006 [code]<?php$test = "my dog";$test2 = strtoupper(substr($test, 0, 1)) . substr($test,1);?>[/code] Quote Link to comment Share on other sites More sharing options...
NovaHaCker Posted December 17, 2006 Share Posted December 17, 2006 [quote author=mlin link=topic=119009.msg486802#msg486802 date=1166388321]select * from table_name where column like 'a%'[/quote]I agree, best to solve as many data issues at the sql script instead of sorting this out in PHP, so the above SQL query would be correct. 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.