I am writing to PHP site for accounting data, payment and attendance of students.
enter image description here

How can I add all the visits at once? For example, to withdraw from the database of all who should have come today, then put a tick on those who attended the lesson. But I do not understand how to do it. All data must be entered in separate cells in order not to beat down the calculation of payment.

Closed due to the fact that the essence of the question is not clear to the participants of Dmitriy Simushev , Denis , Kromster , pavel , tutankhamun 14 Sep '16 at 4:13 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

    2 answers 2

    1. To begin, slightly change the architecture of the database:
      • student table (student id, full name - let it be called StudentTable)
      • class record table (student id, class date, attendance flag — let it be called UchetZanyatiy)
    2. Complete the class schedule in advance by placing a visiting flag of 0 in front of the students.
    3. In the php script that you open first (for example, index.php ), we write something like:

       $conn = mysqli_connect($Server,$DB_User,$DB_Password,$DB_Name); // Получаем идентификаторы и ФИО студентов, которые должны прийти на сегодняшнее занятие $sql="SELECT `StudentTable`.`Student_ID`, `StudentTable`.`Student_FIO` FROM `StudentTable` JOIN `UchetZanyatiy` ON `StudentTable`.`Student_ID`=`UchetZanyatiy`.`Student_ID` WHERE `LessonDate`=CURDATE()"; $res = mysqli_query($conn, $sql); if ($res) while ($row=mysqli_fetch_array($res)) Students[$row['Student_ID']]=$row['Student_FIO']; 

      In the two-dimensional array of Students, we store identifiers and full names of students who should come to today's class.

    4. Next, we display a list of students by checkboxes in front of each, for which we iterate over an array with student IDs, for example, something like this:

       <form method="post" action="write.php"> <?php foreach ($Students as $id => $fio): ?> <input type="checkbox" name="<?=$id?>"><?=$fio?><br> <?php endforeach; ?> <input type="submit" value="Записать"> </form> 

      It turns out a beautiful list of names with checkboxes, and the button below.

      Clicking on the button in the second script (which we call write.php ) in the $ _POST variable will be passed an array of data, including identifiers of selected students. Now it is most reasonable to send this entire array to the database:

       $sql="INSERT INTO `UchetZanyatiy` (`Student_ID`,`Prishel`) VALUES "; foreach ($_POST as $id=>$value) $sql.="('".$id."','1'),"; $sql=substr($sql,0,-1); $sql.=" WHERE `LessonDate`=CURDATE()"; mysqli_query($conn,$sql); 

    PS: possible errors, please forgive - wrote on my knee.

      You take an array that you received based on the answers and loop through it in terms of conditions. If the student has attended the class then you make a request to the database for affixing the mark. If you have an array in which only the data about the students present is formed, then you can build a query with the IN construct.