简体   繁体   English

PHP MYSQL 每天一次的出勤限制

[英]PHP MYSQL Attendance Limit Once a Day

I am Beginner in php and i am making the project on attendance system but i don't know how to code for single-day attendance for the student once in a day.我是 php 初学者,我正在制作考勤系统项目,但我不知道如何为学生一天一次的单日考勤编码。 I didn't get the appropriate result.我没有得到适当的结果。 Thanks in advance.提前致谢。

<?php
include 'config.php';

    if($_SESSION['user']==true){
        if(isset($_POST['submit'])){

              $sql= ("INSERT INTO `student_attendence`(`Student_id`,`Date`,`Attendence`) VALUES ('".$_SESSION['user']."','$date','$attendence') ");

                if(count($error)==0){
                    if(!mysqli_query($conn,$sql)){
                        echo "Error ".mysqli_error($conn);

                    }
                    else{
                        header("location:studentlogin.php");
                    }
                }        
        }
    }   
    else{
        header("location:studentlogin.php");
    }

?>

You have to increase one more attribute in DB table which is date .您必须在 DB 表中增加一个属性,即date
So whenever you insert a new attendence insert today's date also.因此,每当您插入新的出勤时,也要插入今天的日期。
Always check for today's date must not present in DB before inserting the attendence.在插入出勤之前,始终检查今天的日期不得出现在 DB 中。
So while inserting the attendence in DB, you must have to check first -因此,在将出席情况插入数据库时​​,您必须先检查 -

If today's date is already present in DB
   true : display message(today's attendence has already taken).

   false: save the attendence in DB.

Note - MySQL's default DATE format is YYYY-MM-DD .注意 - MySQL 的默认 DATE 格式是YYYY-MM-DD

This is the quick method you can impliment.这是您可以实施的快速方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM