mhouldridge wrote:Hi,
I have the following if statement which checks on other values from a list box;
Code: Select all
if ($list == "asset", "customer", "title", "oslicense") {
$result = mysql_query("SELECT * FROM dedicated WHERE $list LIKE '%$search%' ORDER BY asset");
}
I get unexpected"," error.... any ideas?
You can't compare multiple values at one shot like that. If you want to do it with one if statement, then it's better to do ...
Code: Select all
if ($list == "asset" || $list == "customer" || $list == "title" || $list == "oslicense")
{ /* do stuff */ }
A switch would work here too, but the use of one or the other depends on a lot of other things I won't get into
here. Especially considering some of it may be a matter of opinion.
Now if what you really want is to check each of those items in the list (asset, customer, title, osilcense), then just put them in an
array and iterate.
Code: Select all
$list=array('asset', 'customer', 'title', 'osilcense')
foreach($list as $item)
{ /* do stuff with $item */ }
Cheers