i have table called config contian config_name | config_value
know i want to extract it
like that
`config_name` | `config_value`
`articles_limit` | `10`
now i want php code give me an array like that articles_limit => 10
i have table called config contian config_name | config_value
know i want to extract it
like that
`config_name` | `config_value`
`articles_limit` | `10`
now i want php code give me an array like that articles_limit => 10
You might like to try using a database wrapper like ADODb, where such a thing would simply be
$config=$db->GetAssoc('select config_name, config_value from config');
As plain PHP, this would something like this
$config=array();
$result = mysql_query('select config_name, config_value from config');
if (!$result)
{
//handle error
die(mysql_error());
}
else
{
while ($row = mysql_fetch_assoc($result))
{
$config[$row['config_name']] = $row['config_value'];
}
mysql_free_result($result);
}