Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start(); // NEVER forget this!
- ?>
- <!DOCTYPE html>
- <html>
- <head><script type="text/javascript">
- window.onload = function(){
- var text_input = document.getElementById ('id');
- text_input.focus ();
- text_input.select ();
- }
- </script>
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
- <script type="text/javascript">
- $(document).ready(function() {
- $("#license_no_update").submit(function() {
- var license_no_update = $(this).serialize();
- $.post('license_update.php', license_no_update, function(data) {
- // We not pop the output inside the #output DIV.
- $("#output").html(data);
- });
- return false;
- });
- });
- </script>
- <link rel="stylesheet" type="text/css" href="style.css">
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title></title>
- </head>
- <body><div class="return_to_main"><a href="index.php"><img src="images/main_page.jpg" /></a></div>
- <center>Search for Student - Scan Barcode:<form action="view_student.php" mathod="POST">
- <input type="text" name="id" id="id" size="20" autofocus />
- </form><?php
- //connect to DB
- $conn = mysql_connect('details hidden. ');
- mysql_select_db("web77-fsma", $conn) or die(mysql_error());
- //find total number of students.
- $beginners = mysql_query("SELECT * FROM students WHERE class = 'Child Beginners' AND status <> 'Suspended'");
- $intermediate = mysql_query("SELECT * FROM students WHERE class = 'Intermediate' AND status <> 'Suspended'");
- $advanced = mysql_query("SELECT * FROM students WHERE class = 'Advanced' AND status <> 'Suspended'");
- $adults = mysql_query("SELECT * FROM students WHERE class = 'Adults' AND status <> 'Suspended'");
- $lm = mysql_query("SELECT * FROM students WHERE class = 'Little Monsters' AND status <> 'Suspended'");
- $total = mysql_query("SELECT * FROM students WHERE status <> 'Suspended'");
- $suspended = mysql_query("SELECT * FROM students WHERE status = 'Suspended'");
- //display totals
- echo '<b>Total Students: </b>'.mysql_num_rows($total) .' ¦ <b>Total Suspended:</b> '.mysql_num_rows($suspended).'<br />';
- echo '<b>Little Monsters:</b> '.mysql_num_rows($lm).' ¦ <b>Child Beginners:</b> ' . mysql_num_rows($beginners) .' ¦ <b>Intermediate:</b> ' .mysql_num_rows($intermediate).' ¦ <b> Advanced:</b> ' . mysql_num_rows($advanced).' ¦ <b> Adults: </b>' .mysql_num_rows($adults).' <br />';
- ?><table >
- <tbody>
- <tr class="header">
- <td><b>Name</b></td>
- <td><b>DOB</b></td>
- <td><b><center>Age</center></b></td>
- <td><b>Grade</b></td>
- <td><b><center>Last Attended</center></b></td>
- <td><b><center>Venue</center></b></td>
- <td><b>Class</b></td>
- <td><b>Date Joined</b></td>
- <td><b>License No.</b></td>
- <td><b>Status</b></td>
- </tr>
- <?php
- // find_in_set(Class,'Active,2 Week Trial,4 Week Trial,Suspended,Cancelled),
- $sql = mysql_query("SELECT * from students ORDER BY name");
- while($row = mysql_fetch_array($sql))
- {
- $student_id = $row['student_id'];
- ?> <tr class="<?php echo $row['status']; ?>">
- <td><a href="view_student.php?id=<?php echo $row['student_id']; ?>"><?php echo $row['name']; ?></a></td>
- <td><?php $dob = date('d M Y', strtotime($row['dob'])); echo $dob; ?></td>
- <td><center><?php $dob = $row['dob'];
- $today = date('d-m-Y');
- $diff = abs(strtotime($dob) - strtotime($today));
- $years = floor($diff / (365*60*60*24));
- $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
- $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
- //printf("%d years \n", $years, $months, $days);
- echo $years.'yrs';
- ?></center>
- </td>
- <td><?php //find current grade
- $sql2 = mysql_query("SELECT * FROM gradings WHERE (student_id = ".$student_id.")ORDER BY ID DESC LIMIT 1")or die(mysql_error());
- if($row2 = mysql_fetch_array($sql2)){ echo $row2['grade'];
- }else{ echo 'N/A'; }?></td>
- <td><center><?php //find last attended date.
- $sql2 = mysql_query("SELECT * FROM attendance WHERE (student_id = ".$student_id.")ORDER BY date DESC LIMIT 1")or die(mysql_error());
- if($row2 = mysql_fetch_array($sql2)){ echo $row2['date'];
- }else{ echo 'N/A'; }?></center></td>
- <td><center><?php echo $row['venue']; ?></center></td>
- <td><?php echo $row['Class']; ?></td>
- <td><?php $date_joined = date('d M Y', strtotime($row['date_joined'])); echo $date_joined; ?></td>
- <td><?php // check if license number exists.
- if($row['license_no'] == '')
- {
- //show form.
- ?>
- <form method="POST" id="license_no_update"">
- <input type="text" name="license_no" value="License Number" />
- <input type="hidden" value="<?php echo $row['student_id']; ?>" name="student_id" />
- </form>
- <div id="output"></div>
- <?php
- }else{
- //show license no.
- echo $row['license_no'];
- }
- ?></td>
- <td><?php echo $row['status']; ?></td>
- </tr>
- <?php
- }
- ?>
- </tbody>
- </table></center>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment