mysqli中的这个查询有问题吗?我从mysql转换它,完美地工作,但现在它没有
mysqli_query($con,"SELECT * FROM signed_out_students WHERE date = '$date6' AND time_in = '' order by time_out DESC");
这就是它适合实际代码的方式。我知道数据库中有条目与今天的日期,但它没有显示它们? d:
else if (out == $display) {
date_default_timezone_set('NZ');
$date6 = date('d.m.Y');
$result4 = mysqli_query($con,"SELECT * FROM signed_out_students WHERE date = '$date6' AND time_in = '' order by time_out DESC");
echo '<table border="0">';
echo '<tr>';
echo '<td width="70px"><h2>Date</h2>';
echo '</td>';
echo '<td width="150px"><h2>Name</h2>';
echo '</td>';
echo '<td width="90px"><h2>Form Class</h2>';
echo '</td>';
echo '<td width="70px"><h2>Time Out</h2>';
echo '</td>';
echo '<td width="70px"><h2>Time In</h2>';
echo '</td>';
while($row4 = mysqli_fetch_array($result4))
{
echo '<tr>';
echo '<td><p>' . $row4['date'];
echo '</td>';
echo '<td><p>' . $row4['name'];
echo '</td>';
echo '<td><p>' . $row4['form_class'];
echo '</td>';
echo '<td><p>' . $row4['time_out'];
echo '</td>';
echo '<td><p>' . $row4['time_in'];
if ($row['time_in'] == "") { echo '-';}
echo '</td>';
}
echo '</table>';
}
谢谢你们!
答案 0 :(得分:0)
mysqli中的这个查询有问题吗?
是的,很多。
从这里开始:https://stackoverflow.com/tags/pdo/info
此外,作为附注,您的日期必须为'Y-m-d'
格式。
答案 1 :(得分:-1)
从Query中的变量中删除单引号:
mysqli_query($con,"SELECT * FROM signed_out_students WHERE date = $date6 AND time_in = '' order by time_out DESC");