我目前有一个如下图所示的数据库。
其中有一个查询选择 number1 等于 1 的行。当使用
mysql_fetch_assoc()
在 php 中,我只给出了第一个,有什么方法可以得到第二个?就像通过维度数组一样
array['number2'][2]
或类似的东西
使用重复调用 mysql_fetch_assoc。它记录在 PHP 手册中。
http://php.net/manual/function.mysql-fetch-assoc.php http://php.net/manual/function.mysql-fetch-assoc.php
// While a row of data exists, put that row in $row as an associative array
// Note: If you're expecting just one row, no need to use a loop
// Note: If you put extract($row); inside the following loop, you'll
// then create $userid, $fullname, and $userstatus
while ($row = mysql_fetch_assoc($result)) {
echo $row["userid"];
echo $row["fullname"];
echo $row["userstatus"];
}
如果需要,您可以使用它来构建多维数组,以便在脚本的其他部分中使用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)