我有我的PHP while语句的问题。它是:PHP,而声明问题
$row = mysqli_fetch_array($result);
$time_in_12_hour_format = date("g:i a", strtotime($row['Time']));
while($row = mysqli_fetch_array($result)){ //Creates a loop to loop through results
echo "<tr><td>" . $row['Name'] . "</td><td>" . $row['Description'] . "</td><td>" . $row['Date'] . " at " . $time_in_12_hour_format . "</td><td>" . $row['Location'] . "</td>"; //$row['index'] the index here is a field name
是的,我意识到我定义$行两次,但我不知道如何改变这一点。如果我从while语句中删除$ row = mysqli_fetch_array($ result),页面将不会加载并返回错误。截至目前,页面加载但表格是空的,尽管我知道有一个记录在那里显示在表格中,然后我添加了军事时间转换器。任何帮助表示赞赏。
后完整的代码 –
删除第一个'$行= mysqli_fetch_array($结果);',并添加'$ time_in_12_hour_format =日期( “G:IA” 的strtotime($行[”时间']));'循环。 – CnapoB