Как обновить статус в базе данных?
я новичок в php. я хочу создать страницу посещаемости для репетитора.
<form name="form" method="post" action"admin_attendance_edit.php> <table> <thead> <tr> <th>No.</th> <th>Name</th> <th>Status</th> </tr> </thead> <tbody> <?php $count=1; $sel_query="Select * from attendance ORDER BY attendance_id desc;"; $result = mysqli_query($db,$sel_query) or trigger_error("Error". mysqli_error($db)); while($row = mysqli_fetch_assoc($result)) {?> <tr> <td align="center"><?php echo $count; ?></td> <td align="center"><?php echo $row["student_name"]; ?></td> <td align="center"> <input type="hidden" name="user_id[]" value="<?php echo $row["user_id"];?>" /> <input type="hidden" name="name[]" value="<?php echo $row["student_name"]; ? >" /> <input name="attendance[]" type="radio" value="present" />Present <input name="attendance[]" type="radio" value="late"/>Late <input name="attendance[]" type="radio" value="absent"/>Absent</td> </tr> <?php $count++; } ?> </tbody> </table> <p><input name="submit" type="submit" value="Update" /></p> </form>
<?php if(isset($_POST['submit'])) { foreach ($attendance as $name=> $attendance_status) { $trn_date = date('Y-m-d'); $user_id = $_POST['user_id'][$name]; $student_name = $_POST['name'][$name]; $update="update attendance set user_id='".$user_id."', student_name='".$student_name."' , attendance_status='".$attendance_status."', date='".$trn_date."' "; mysqli_query($db, $update) or trigger_error( "Error!". mysqli_error($db)); header('location: admin_attendance.php'); }
Что я уже пробовал:
Can anyone tell me anything wrong in my code.thanks.