I am trying to compare the field names in the table against the $_GET field names and if it exists in the table create a Query string, and i am trouble loading the mysql_field_name into an array if i do them individually like $t1 = mysql_field_name($result,1); it works but loading them all like $vars = mysql_field_name($result); dose not seem to work.
This dose not work
$query = array();
$result = mysql_query("SELECT * FROM search_prof");
$vars = mysql_field_name($result);
foreach ($vars as $v)
{
if (isset($_GET[$v]))
{
$query[] = $v.' = "'.addslashes($_GET[$v]).'"';
}
}
$query = implode(' AND ', $query);
This works
$t1 = mysql_field_name($result,1);
$t2 = mysql_field_name($result,2);
$t3 = mysql_field_name($result,3);
$t4 = mysql_field_name($result,4);
$t5 = mysql_field_name($result,5);
$query = array();
$result = mysql_query("SELECT * FROM search_prof");
$vars = array('$t1', '$t2', '$t3', '$t4', '$t5');
foreach ($vars as $v)
{
if (isset($_GET[$v]))
{
$query[] = $v.' = "'.addslashes($_GET[$v]).'"';
}
}
$query = implode(' AND ', $query);