【发布时间】:2018-12-21 08:09:36
【问题描述】:
我正在编写一个 php 文件,我想通过执行 2 个单独的查询来显示两个表,并将它们存储在 $result 和 $result_bike 中。但是,当我尝试打开此操作表单的 html 页面时,它仅显示第一个查询的表,并在第二个位置出现错误“命令不同步;您现在无法运行此命令”桌子。
另外,我不想合并这两个表,因为它们显示完全不同的信息,我想插入一些文字来解释每个表。
我认为可能与无法为 php 打印两个表有关(我对此表示怀疑)?我应该做出什么改变?
提前感谢您的帮助!
$result = mysql_query("CALL CrashTypeRate_Ped('$city')", $conn);
if (!$result){
echo "Fail to retrieve result for pedestrian crashes!\n";
print mysql_error();
} else {
echo "<table border=1>\n";
echo "<tr><td>CrashType</td><td>Count</td><td>TotalCount</td></tr>\n";
while ($myrow = mysql_fetch_array($result)) {
printf("<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n", $myrow["crash_type"], $myrow["type_count"], $myrow["total_count"]);
}
echo "</table>\n";
}
$result_bike = mysql_query("CALL CrashTypeRate_Bike('$city')", $conn);
if (!$result_bike) {
echo "Fail to retrieve result for bike crashes!\n";
print mysql_error();
} else {
echo "got here!!!!!!";
echo "<table border=1>\n";
echo "<tr><td>CrashType</td><td>Count</td><td>TotalCount</td></tr>\n";
while ($myrow = mysql_fetch_array($result_bike)) {
printf("<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n", $myrow["crash_type"], $myrow["type_count"], $myrow["total_count"]);
}
echo "</table>\n";
}
【问题讨论】: