【发布时间】:2018-07-17 01:10:18
【问题描述】:
此代码仅显示一行。当我执行其中一个查询时,如何显示 MySQL 表中的其他行? 感谢您提供的任何东西!感谢您的帮助!
// Display query results in a table
if ($queryresults) {
$row = $queryresults->fetch_assoc(); // Problem is here or below
echo "<table> <tbody><tr><th>Name</th><th>Start Time</th>";
echo "<th>Duration</th><th>End Time</th>";
while($row) {
// Create row of table
$str = "<tr><td>". $row['name']."</td><td>". $row['starthour'].":";
$str .= format2($row['startmin'])." ". $row['ampm']."</td><td>". $row['hours'];
$str .= "h ". format2($row['minutes'])."m</td><td>". $row['endhour'].":";
$str .= format2($row['endmin'])." ". $row['endampm'] . "</td></tr>";
echo $str;
$row = $queryresults->fetch_assoc($queryresults);
}
echo "</tbody></table>";
} else {
echo "Error: #".$connection->errno." – ".$connection->error;
}
// Logout of server
$connection->close();
【问题讨论】:
-
如果需要,我很乐意提供更多信息!
-
您不能使用 query($query) 运行多个查询。它只运行 $a
-
我很困惑这行: $query = (($month != 'All') and ($day != 'All')) ? $a : $b;
-
我不确定是否可以将此标记为与此重复 stackoverflow.com/questions/51286142/…