]> git.treefish.org Git - banana.git/blob - admin/blackboard.php
submit as often as you want.
[banana.git] / admin / blackboard.php
1 <?php
2   require 'include/head.inc';
3   require 'include/db.inc';
4   require 'include/common.inc';
5   
6   if(isset($_POST['submit']) && $_POST['mnumber']!="") {
7     $db->query("UPDATE students SET blackboard=blackboard+1 WHERE mnumber=" . trim($_POST['mnumber']));
8     block("lightgreen", "added blackboard");
9   }
10
11   if ($db->query("SELECT COUNT(*) FROM students")->fetch(PDO::FETCH_NUM)[0] == 0) {
12     block("red", "no students registered");
13     exit;
14   }
15
16   block("black", "add blackboard");
17 ?>
18
19 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
20   <table>
21     <tr>  
22       <th align="left">Matr.nummer:</th> <th><input type="text" name="mnumber"></th>
23       <th><input type="submit" name="submit" value="Add"></th>
24     </tr>
25   </table>
26 </form>
27
28 <?php
29   block("black", "blackboard overview");
30
31   $result=$db->query("SELECT firstname, lastname, mnumber, blackboard FROM students");
32
33   print "<table>";
34   while ($student = $result->fetch(PDO::FETCH_ASSOC)) {
35     print "<tr>";
36     print "<td>" . $student['firstname'] . "&nbsp;</td>";
37     print "<td>" . $student['lastname'] . "&nbsp;&nbsp;</td>";
38     print "<td>" . $student['mnumber'] . "&nbsp;&nbsp;</td>";
39     print "<td>" . $student['blackboard'] . "</td>";
40     print "</tr>";
41   }
42   print "</table>";
43      
44 ?>