Advertisement
michaelyuen

Untitled

Apr 20th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.38 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require('connection.php');
  4. ?>
  5. <!DOCTYPE html>
  6. <html>
  7.     <head>
  8.         <title>Peon</title>
  9.         <link rel="stylesheet" href="assets/css/style.css">
  10.         <link rel="stylesheet" href="assets/css/bootstrap.min.css" />
  11.     </head>
  12.     <body>
  13. <?php
  14. if(ISSET($_SESSION['id'])) {
  15.     $id = $_SESSION['id'];
  16.     $fetch = "SELECT * FROM user_info WHERE id='$id';";
  17.     $query = mysql_query($fetch);
  18.     if(!$query) {
  19.         echo mysql_error();
  20.     } else {
  21.         $array=mysql_fetch_array($query);
  22. ?>
  23.     <h1 style="text-align:center">Welcom to you profile page <span><?php echo $array['name']; ?></span></h1>
  24. <?php
  25.     }
  26. }
  27. ?>
  28.     <div id="peon">
  29.     <form name="attendence_form" action="" method="POST">
  30.         <table class="table table-bordered">
  31.             <tr>
  32.                 <th>Teacher Name</th>
  33.                 <th>Subject</th>
  34.                 <th>Class</th>
  35.                 <th>Room #</th>
  36.                 <th>Attendence</th>
  37.                 <th>Submit</th>
  38.             </tr>
  39. <?php
  40. $fetch = "SELECT * FROM period;";
  41. $query = mysql_query($fetch);
  42. if(!$query) {
  43.     echo mysql_error();
  44. } else {
  45.     WHILE($array = mysql_fetch_array($query)) {
  46. ?>
  47.             <tr>
  48.                 <td><input type="text" value="<?php echo $array['teacher_name']; ?>" class="form-control" name="t_name[]" /></td>
  49.                 <td><input type="text" value="<?php echo $array['subject']; ?>" class="form-control" name="subject[]" /></td>
  50.                 <td><input type="text" value="<?php echo $array['class']; ?>" class="form-control" name="class[]" /></td>
  51.                 <td><input type="text" value="<?php echo $array['room']; ?>" class="form-control" name="room[]" /></td>
  52.                 <td>
  53.                     <select name="attendence[]" class="form-control">
  54.                         <option value="Present">Present</option>
  55.                         <option value="Absent">Absent</option>
  56.                     </select>
  57.                 </td>
  58.                 <td><button type="submit" name="btn_sub" class="btn btn-default">Submit</button></td>
  59.             </tr>
  60. <?php
  61.     }
  62. }
  63. ?>
  64.         </table>
  65.     </form>
  66.     </div>
  67. <?php
  68.     if (ISSET($_POST['btn_sub'])) {
  69.         $count = $_POST['t_name'];
  70.         for ($i = 0; $i < $count; $i++) {
  71.             $teacher = $_POST['t_name'][$i];
  72.             $subject = $_POST['subject'][$i];
  73.             $class=$_POST['class'][$i];
  74.             $room=$_POST['room'][$i];
  75.             $attendence=$_POST['attendence'][$i];
  76.             $insert="INSERT INTO atendence (teacher_name,subject,class,room,attendence) VALUE ('$teacher','$subject','$class','$room','$attendence');";
  77.             $quer=mysql_query($insert);
  78.             if(!$query) {
  79.                 echo mysql_error();
  80.             }
  81.         }
  82.         header('location: yourphp.php');
  83.     }
  84. ?>
  85. </body>
  86. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement