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"; Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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 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.