Jump to content

Calling database info from db with a LIKE query with a variable?


colleyboy

Recommended Posts

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";

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. :(

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.