即使我的数据库有其值,我的代码也没有返回任何内容

时间:2016-07-30 22:25:11

标签: php mysqli

当我尝试显示$time_4$time_5时,它们没有任何价值,它们根本不会显示,也不会显示在我的屏幕上。我正在从正确的表中查询,我在$ time_1上输入的查询的参数都是正确的,当我手动运行它进入我的数据库时,它会给出正确的结果。

$time_1 = "SELECT * FROM ".ATD_TBL." WHERE nik = '$nik' AND Date = '$date'";
$time_2 = mysqli_query($conn,$time_1);
$time_3 = mysqli_fetch_array($time_2, MYSQLI_ASSOC);
$time_4 = $time_3['clockin'];
$time_5 = $time_3['date'];

1 个答案:

答案 0 :(得分:0)

尝试这个

    <?php
$time_1 = "SELECT * FROM `ATD_TBL` WHERE `nik` = '".$nik."' AND `Date` = '".$date."' ";
    $time_2 = mysqli_query($conn,$time_1);
    $time_3 = mysqli_fetch_array($time_2, MYSQLI_ASSOC);
    $time_4 = $time_3['clockin'];
    $time_5 = $time_3['date'];
    ?>