I’m trying to make a little update script, using the mysql_field_name to keep the form database-driven and not too hard-coded.
But it seems like a query to mysql doesn’t return a string, whether it’s the name of a field, a table, or whatever. So, here’s my code, I’m sure it’s some simple escape operator or built-in php function, but I could either search on the web all night or ask one of you guys that knows.
[code=php]
for($x=0; $x<mysql_numrows($result); $x++)
{
$updatequery = “UPDATE schools SET “;
for($y=2; $y<mysql_num_fields($result); $y++)
{
$updatequery +=(mysql_field_name($result, $y) . “='” . mysql_field_name($result, $y) . $x . “‘, “);
}
$updatequery +=(” WHERE id='” . ($x+1) . “‘”);
$update = mysql_query($updatequery);
echo $updatequery; //for my own debugging purposes
}
^ This returns “0” (most likely because it cannot concatenate the mysql functions as strings.)
Any help is truly appreciated.