Page 1 of 1

An easy Mysql question for an experienced programmer

Posted: Tue May 17, 2005 4:01 am
by mhouldridge
Hi,

I have the following code used for a search box to query my database;

Code: Select all

$result = mysql_query("SELECT * FROM dedicated WHERE customer LIKE '%$search%'");

I need to tweak it so that it incorporates a list box. Here is my tweaked code;

Code: Select all

$result = mysql_query("SELECT * FROM dedicated WHERE '%$list%' LIKE '%$search%'");

As you can see it used both $list and $search. When I echo this within my output script it shows up, but it doesnt appear to work for the query. I dont think mysql is recognising it..

Please help

Posted: Tue May 17, 2005 4:21 am
by onion2k

Code: Select all

$result = mysql_query("SELECT * FROM dedicated WHERE $list LIKE '%$search%'");

Posted: Tue May 17, 2005 5:57 am
by mhouldridge
that's sorted, thanks!

Posted: Tue May 17, 2005 6:14 am
by onion2k
By the way, I hope you're validating these incoming variables in some way. Otherwise it's a teeny bit of a security risk..