将某些变量分配给数组作为键和值

时间:2012-09-16 09:52:08

标签: php html

我有这个表大约有5列

column1, user_id, column3, column4, user_exp

如果我做这样的选择查询

$mat_sql = mysql_query(
 "SELECT * 
  FROM users 
  ORDER BY user_exp DESC LIMIT 10", $general);

我如何只使用user_iduser_expuser_id as the keyuser_exp as the value放入数组中?

由于

1 个答案:

答案 0 :(得分:2)

$mat_sql = mysql_query("SELECT user_id, user_exp FROM users ORDER BY user_exp DESC LIMIT 10", $general);
while ($row = mysql_fetch_assoc($mat_sql)) {
    $result['user_id'] = $row['user_exp'];
}