Hi,
I am currently working with a set of posted variables from a form in php5: $var1, $var2 and $var3. I need to search for them in SQL as an array, and return the results if any of the variables has been entered in in the php form.
I have found an example using PHP4 from a tutorial, but I need to create the same code in PHPv5. Here is the tutorial code:
[COLOR=“YellowGreen”]$searchSQL = $db->query("SELECT Title, Creator, Description FROM ICM WHERE ";
// grab the search types.
$types = array();
$types[] = isset($_GET['var1'])?"`Title` = '$searchTermDB'":'';
$types[] = isset($_GET['var2'])?"`Creator` = '$searchTermDB'":'';
$types[] = isset($_GET['var3'])?"`Description` = '$searchTermDB'":'';
$types = array_filter($types, "removeEmpty");
if (count($types) < 1)
$types[] = "`Description` = '$searchTermDB'";
$andOr = isset($_GET['matchall'])?'AND':'OR';
$searchSQL .= implode(" {$andOr} ", $types) . " ORDER BY `Description`");
$searchResult = mysql_query($searchSQL) or trigger_error("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}");[/COLOR]
I would like to know where I need to change this code in phpv5.
Many thanks in advance.