colleyboy Posted July 27, 2012 Share Posted July 27, 2012 I am trying to call results from a database where a letter is equal to a letter. I have already called the variable $letter; to look at the url and use this result at the variables contents. I.E: $letter = A I am trying to call via MYSQL any rows matching a certain letter. This letter is defined by $letter. I cant seem to put this in correctly? can anyone help? $query="SELECT * FROM products WHERE product_name LIKE '$letter;%' ORDER by variety ASC"; Link to comment https://forums.phpfreaks.com/topic/266342-calling-database-info-from-db-with-a-like-query-with-a-variable/ Share on other sites More sharing options...
Jessica Posted July 27, 2012 Share Posted July 27, 2012 Why do you have a ; after letter? Do you want words that start with the letter or have it anywhere in the name? Link to comment https://forums.phpfreaks.com/topic/266342-calling-database-info-from-db-with-a-like-query-with-a-variable/#findComment-1364886 Share on other sites More sharing options...
colleyboy Posted July 27, 2012 Author Share Posted July 27, 2012 Basically I am trying to call back results which start with the letter. I tried removing the ; but has not worked . If I replace with 'A%' or 'B%' it works fine but cant seem to get it to work with a variable. Link to comment https://forums.phpfreaks.com/topic/266342-calling-database-info-from-db-with-a-like-query-with-a-variable/#findComment-1364888 Share on other sites More sharing options...
colleyboy Posted July 27, 2012 Author Share Posted July 27, 2012 Ah-ha ... many thanks. It worked with '$letter%' Think this is calling the first letter now - I hope :S Link to comment https://forums.phpfreaks.com/topic/266342-calling-database-info-from-db-with-a-like-query-with-a-variable/#findComment-1364890 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.