title: How to save present, absent list of students in database for attendance management system?
body: <p>I want to save the present/absent details of students in database everyday. In my project I cant save it. Don't know how to save this .  I am getting the student name and roll number from another table (table name - student). Help me . Thank you in advance </p>
  
  <p>my database table is like is ,(table name -- attendance)</p>
  
  <pre><code>+---+----------------+-------------+-----------------------------+
  |   |      Name      |    Type     |         Attributes          |
  +---+----------------+-------------+-----------------------------+
  | 1 | id Primary     | int(50)     | No                          |
  | 2 | name           | varchar(20) | No                          |
  | 3 | Roll_Number    | varchar(20) | No                          |
  | 4 | date           | timestamp   | on update CURRENT_TIMESTAMP |
  | 5 | present_absent | varchar(20) | No                          |
  +---+----------------+-------------+-----------------------------+
  </code></pre>
  
  <p>My code is class_attendance. php is below</p>
  
  <pre><code>&lt;?php
       include("php/connect.php");
       include("php/check.php");
  
   $res['role']=$_SESSION['role'];
  
   $hid = $_SESSION['id'];
  
   $errormsg = '';
   $action = "add";
  
    $name ='';
    $Roll_Number =''; 
    $present_absent =''; 
  
   if(isset($_POST['save']))
       {
   $id = mysqli_real_escape_string($conn,$_POST['id']);
   $sql = "select name,Roll_Number from student  ";
  
  
    $sql = $conn-&gt;query("INSERT INTO attendance (name,Roll_Number,present_absent)
    VALUES ('$name','$Roll_Number','$present_absent')") ;
  
      echo '&lt;script type="text/javascript"&gt;window.location="attendance.php";&lt;/script&gt;';
  
   }
  
  
  
   $action = "add";
       if(isset($_GET['action']) &amp;&amp; $_GET['action']=="edit" )
   {
     $id = isset($_GET['id'])?mysqli_real_escape_string($conn,$_GET['id']):'';
  
    $sqlEdit = $conn-&gt;query("SELECT * FROM attendance WHERE id='".$id."'");
   if($sqlEdit-&gt;num_rows)
    {
     $rowsEdit = $sqlEdit-&gt;fetch_assoc();
    extract($rowsEdit);
     $action = "update";
   }
   else
    {
      $_GET['action']="";
    }
  
  }
  
  
    if(isset($_REQUEST['act']) &amp;&amp; @$_REQUEST['act']=="1")
   {
    $errormsg = "&lt;div class='alert alert-success'&gt; &lt;a href='#' class='close' 
    data-dismiss='alert' aria-label='close'&gt;&amp;times;&lt;/a&gt;
    &lt;strong&gt;Success!&lt;/strong&gt; Student Add successfully&lt;/div&gt;";
   }
  
  ?&gt;
  
  
  
  
  &lt;div class="panel panel-default"&gt;
      &lt;div class="panel-heading"&gt;
              Manage Student  
     &lt;? php echo "Today is " . date("m/d/Y") . "";?&gt;
      &lt;/div&gt;
  &lt;div class="panel-body"&gt;
   &lt;div class="table-sorting table-responsive"&gt;
    &lt;table class="table table-striped table-bordered table-hover id="Sortable"&gt;
           &lt;thead&gt;
                 &lt;tr&gt;
                     &lt;th&gt;S.No&lt;/th&gt;
                     &lt;th&gt;Roll Number&lt;/th&gt;
                     &lt;th&gt;Name&lt;/th&gt;
                     &lt;th&gt;Attendance&lt;/th&gt;
                  &lt;/tr&gt;
             &lt;/thead&gt;
           &lt;tbody&gt;
  
  &lt;form method="post" action="class_attendance .php" id="attendance_Form"&gt;
              &lt;?php if(isset($_GET["id"]))  
   { 
      $sql = "SELECT * FROM student as s,branch as b WHERE s.branch=b.id and b.id='".$_GET['id']."' and s.delete_status='0' " ;
          $q = $conn-&gt;query($sql);
          $i=1;
          while($r = $q-&gt;fetch_assoc())
              {
  
              echo '&lt;tr &gt;
                       &lt;td&gt;'.$i.'&lt;/td&gt;
                       &lt;td&gt;'.$r['Roll_Number'].'&lt;/td&gt;
                       &lt;td&gt;'.$r['name'].'&lt;/td&gt;
                       &lt;td&gt; 
  &lt;select  class="form-control" id="present_absent" name="present_absent"&gt;                      
         &lt;option  if ($present_absent == "Present" ) echo "selected" value="Present"&gt;Present&lt;/option&gt;
         &lt;option  if ($present_absent == "Absent" ) echo "selected"  value="Absent"&gt;Absent&lt;/option&gt;
  
                        &lt;/select&gt;
                       &lt;/td&gt;
                     &lt;/tr&gt;';
                  $i++;
                          }
   }
  
                       echo "&lt;/table&gt;";
                              ?&gt;
                       &lt;button type="submit" name="save" &gt;Save &lt;/button&gt;
              &lt;/form&gt;
            &lt;/tbody&gt;
          &lt;/table&gt;
        &lt;/div&gt;
      &lt;/div&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>This is how I save the attendance: <img src="https://i.stack.imgur.com/x32qZ.png" alt="this is how I save the attendance"></p>
  
  <p>When I submit the attendance, students name and their present absent list should be saved every day with respective date.</p>