X-Git-Url: http://git.treefish.org/banana.git/blobdiff_plain/8db41c98817b1b48532dc3cebf4bea166e42bb70..75c95fb6291c3baacfe1883b3f1207c2b34fd78c:/admin/blackboard.php?ds=sidebyside diff --git a/admin/blackboard.php b/admin/blackboard.php index b683221..6571f39 100644 --- a/admin/blackboard.php +++ b/admin/blackboard.php @@ -3,27 +3,28 @@ require 'include/db.inc'; require 'include/common.inc'; - if(isset($_POST['submit']) && $_POST['mnumber']!="") { - $db->query("UPDATE students SET blackboard=blackboard+1 WHERE mnumber=" . trim($_POST['mnumber'])); - block("lightgreen", "added blackboard"); + if( isset($_GET['mnumber']) && + $db->query("SELECT COUNT(*) FROM students WHERE mnumber=" . trim($_GET['mnumber']) . " AND lastblackboard=" . trim($_GET['tstamp']))->fetch(PDO::FETCH_NUM)[0] == 0) { + + if( $_GET['sign'] == 0 ) { + $db->query("UPDATE students SET blackboard=blackboard+1, lastblackboard=" . $_GET['tstamp'] . " WHERE mnumber=" . trim($_GET['mnumber'])); + } + else { + $db->query("UPDATE students SET blackboard=blackboard-1, lastblackboard=" . $_GET['tstamp'] . " WHERE mnumber=" . trim($_GET['mnumber'])); + } } - block("black", "add blackboard"); -?> + if ($db->query("SELECT COUNT(*) FROM students")->fetch(PDO::FETCH_NUM)[0] == 0) { + block("red", "no students registered"); + exit; + } -
+?> query("SELECT firstname, lastname, mnumber, blackboard FROM students"); + $result=$db->query("SELECT firstname, lastname, mnumber, blackboard FROM students ORDER BY LOWER(lastname)"); print "" . $student['firstname'] . " | "; print "" . $student['lastname'] . " | "; print "" . $student['mnumber'] . " | "; - print "" . $student['blackboard'] . " | "; + print "" . $student['blackboard'] . " | "; + print "" . "+1" . " | "; + print "" . "-1" . " | "; print ""; } print "