Attendance system in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jitusorout
Forum Newbie
Posts: 1
Joined: Tue May 27, 2014 10:16 pm

Attendance system in php

Post by jitusorout »

I want to take students attendance.
i had made a page attendance.php
This is coding part

Code: Select all

    <?php
$report = mysql_query("SELECT id, name, rollno FROM registered_members") or die(mysql_error());
?>
<form action="attendinsert.php" method="post">
<table id = "attendance" width="567" border="1 bold">
  <tr>
    <th width="83" scope="col">ID</th>
    <th width="83" scope="col">Student Name</th>
    <th width="55" scope="col">Student Roll.No</th>
    <th width="51" scope="col">Attendance</th>
  </tr>
  <?php while(list($id, $name, $rollno) = mysql_fetch_row($report))
  {
  ?>
  <tr>
    <td><?php echo $id ?></td>
    <td><?php echo $name ?></td>
    <td><?php echo $rollno ?></td>
    <td align="center"><?php echo '<input type="hidden" name="att[]" value="0"/>';?><?php echo '<input type="checkbox" checked="checked"  name="att[]" value="1"  />'; ?></td>
    <input type="hidden" name="rollno[]" value="<?php echo $rollno; ?>"  />
  </tr>
<?php
  }
  echo '</table>';
  ?>
  <input type="submit" name ="submit2"  id="submit2" value ="submit"></input>
</form>

///////////////////////////////////////////////////////


And the second page is attendinsert.php
by which i want to save data in attendance table


Code: Select all

<?php
$att = $_POST['att'];
$rollno = $_POST['rollno'];
            foreach($att as $key => $attendance) {
                          $at = $attendance ? '1' : '0';
                $query = "INSERT INTO `attendance`(`rollno`,`att`) VALUES ('".$rollno[$key]."','".$at."') ";
                $result = mysql_query($query);
            }           
?>
I dont know whats the error. on line

Code: Select all

 $query = "INSERT INTO `attendance`(`rollno`,`att`) VALUES ('".$rollno[$key]."','".$at."') ";
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Attendance system in php

Post by Celauran »

What does mysql_error() say the error is?
Post Reply