I have a table called global_settings with 2 columns (field, value)
i need a way to make each row a variable
so for example:
is field = title and value = hello i would need:
$title = 'hello';
I have tried doing this:
$global_sql="SELECT * from global_settings ";
$global_rs=mysql_query($global_sql,$conn) or die(mysql_error());
while($global_result=mysql_fetch_array($global_rs))
{
$global_sql2="SELECT * from global_settings where field = '".$global_result["field"]."' ";
$global_rs2=mysql_query($global_sql2,$conn) or die(mysql_error());
$global_result2=mysql_fetch_array($global_rs2);
$global_result2["field"] = $global_result2["value"];
}
but that didn't work - any ideas?
$global_settings[$field] = $value. Do you really need to make them specific variables?$config[$global_result2["field"]] = $global_result2["value"];- just replace the last line of your loop with that. You should also initialise the value of$configbefore the loop, too.