-1
我有表config
contian config_name
| config_value
知道我要提取它 像php array任何mysql問題
`config_name` | `config_value`
`articles_limit` | `10`
現在我想的PHP代碼給我像一個數組 articles_limit => 10
我有表config
contian config_name
| config_value
知道我要提取它 像php array任何mysql問題
`config_name` | `config_value`
`articles_limit` | `10`
現在我想的PHP代碼給我像一個數組 articles_limit => 10
你可能會喜歡使用一個數據庫包裝像ADODb嘗試,其中,這樣的事情,簡直是
$config=$db->GetAssoc('select config_name, config_value from config');
爲純PHP,這將是這樣的
$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);
}
不,我不會用它請告訴我用的方式 – 2010-07-10 21:17:28
以及通常的方式是使用包裝而不是寫所有的! – 2010-07-10 21:21:20
新程序應該使用mysqli擴展。 – Artefacto 2010-07-10 21:54:21