此代码仅显示一行。在执行其中一个查询时,如何显示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();
1条答案
按热度按时间oewdyzsn1#
你能试试吗:
把其他的都去掉
$row
转让。我认为你叫fetch\u assoc()的方式有误