我想更改mysql结果的格式......
[0] =>
[id] => 1
[name] => King
[1] =>
[id] => 5
[name] => Queen
采用以下格式:
[1] => King
[5] => Queen
但我不知道如何将mysql结果放入这种格式。
$teamSql = "SELECT id, name FROM users WHERE projectid = '1';
$teamQuery = mysql_query($teamSql);
$teamFetch= mysql_fetch_assoc($teamQuery);
// and now?
答案 0 :(得分:5)
$teamSql = "SELECT id, name FROM users WHERE projectid = '1'";
$teamQuery = mysql_query($teamSql);
$teams = array();
while ($team = mysql_fetch_array($teamQuery))
{
$teams[$team['id']] = $team['name'];
}
答案 1 :(得分:-1)
用于在PHP中显示结果,
使用foreach循环
像foreach一样($ teamFetch为$ teamFetched){echo $ teamFetched;
}
多数民众赞成......