Attendance system in php

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

jitusorout
New php-forum User
New php-forum User
Posts: 1
Joined: Tue May 27, 2014 6:12 pm

Attendance system in php

Postby jitusorout » Tue May 27, 2014 6:23 pm

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>




Now i want to save these value with attendinsert.php

here the code

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 problem
its showing error on line .

Code: Select all

 $query = "INSERT INTO `attendance`(`rollno`,`att`) VALUES ('".$rollno[$key]."','".$at."') ";


If somebody have any other query sombody says PDO
please share with me

my mail is jitu.sorout@gmail.com

Thanks in advance

developerahusain
New php-forum User
New php-forum User
Posts: 44
Joined: Tue May 28, 2013 10:04 pm
Location: India,Lucknow

Re: Attendance system in php

Postby developerahusain » Sat May 31, 2014 10:59 pm

<?
function insert_data($num) { //////////////function 6
if($num>0){
$ins=0;
$str="";
while($ins<$num){
$ins=$ins+1;

if ($_POST ['roll_no'.$ins])
{

if(mysql_query("insert into table(roll_no) values ('"
.$_POST ['roll_no'.$ins]."')") or die("the eror ".mysql_error()));

}
}
}
}

if ($_POST ['b_submit'])
{
echo insert_data ("100");
} ?>
<form name="asdf" method="post">
<? $quer2=mysql_query("select * from table");
while($resul2=mysql_fetch_array($quer2))
{
$f++;
?>

<tr><td><input type="checkbox" value="<?=$resul2 ['roll_no'] ?>" name="roll_no<?=$f ?>" ></td></tr><?
}
?>
<tr><td><input type="submit" class="style_form" name="b_submit" value="Submit'></td></tr>
</form>

This will do as per your requirements.Any problem do revert.Do confirm if worked properly

Developerahusain


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 5 guests