I need proper syntax/procedure for inserting a variable into a SELECT query...
Hello All,
Here's what I want to do:
Take this - $sql = 'SELECT name FROM galleries WHERE spec = XYZ'
where XYZ is a variable passed down from a query string.
What is the proper syntax/procedure for placing a variable in the above statement? I'm trying everything I can think of to no avail.
For what it's worth, I'm using MySQLi.
Thanks in advance for any help you can offer!
Sincerely,
wordman
I need proper syntax/procedure for inserting a variable into a SELECT query...DONE
Quit looking, I found it.
This is the part that I was missing. I found it on a php developer forum and just tested it...works perfect!
$sql = "SELECT g_name, g_desc FROM galleries WHERE g_spec = '$spec%' " ;
What I didn't know was that I had to surround the variable in quotes and add the % at the end. Now, I can pull the data from my DB however I like and it works.
I wanted to post this here in case anyone else had a similar hitch.
Many thanks to everyone here for your help!
Cheers,
wordman