i have a select query that will check if the id is exist then it will fetch the data of it and then i place a select query on another table that will check if the timeout column is empty because i want the user/student to timeout first before he or she can time-in again, and if not it will execute the insert query, the insert query is working if the table student_att has value, but when i delete all the records in the student_att it is not inserting any data. hope you can help me fix my code. advance thanks.
here is my php code:
<?php
include_once('connection.php');
if(isset($_POST['submit0'])){
$rfid = $_POST['rfid'];
$time=date("H:i:s");
$sql = mysqli_query($conn,"select * from stud where rfid_num ='$rfid' ");
$count = mysqli_num_rows($sql);
if ($count == 0) {
header("location:notexist.php");
}else{
while( $row = mysqli_fetch_array($sql)) {
$rfid=$row['rfid_num'];
$id=$row['id'];
$name0 = $row['name'];
$course0 = $row['course'];
$image = $row['image'];
$sql1 = mysqli_query($conn,"select * from student_att where rfid_num ='$rfid' order by number DESC limit 1 ");
while( $row = mysqli_fetch_array($sql)) {
if(empty($row['timeout'])){
header("location:logout.php");
}else{
$InsertSql = mysqli_query($conn,"INSERT INTO student_att(rfid_num,id,name,course,image,timein) VALUES ('$rfid','$id','$name0','$course0','$image','$time')");
}
}
}
}
}
?>