X-Git-Url: https://git.treefish.org/banana.git/blobdiff_plain/78533c089d9413327f981cb2b20090a28f25e5e5..df32c63a6e9666eb062f806262aa23ed43c6eb99:/admin/blackboard.php diff --git a/admin/blackboard.php b/admin/blackboard.php index 139abe9..6571f39 100644 --- a/admin/blackboard.php +++ b/admin/blackboard.php @@ -3,9 +3,15 @@ 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'])); + } } if ($db->query("SELECT COUNT(*) FROM students")->fetch(PDO::FETCH_NUM)[0] == 0) { @@ -13,22 +19,12 @@ exit; } - block("black", "add blackboard"); ?> -
- - - - - -
Matr.nummer:
-
- query("SELECT firstname, lastname, mnumber, blackboard FROM students"); + $result=$db->query("SELECT firstname, lastname, mnumber, blackboard FROM students ORDER BY LOWER(lastname)"); print ""; while ($student = $result->fetch(PDO::FETCH_ASSOC)) { @@ -36,7 +32,9 @@ print ""; print ""; print ""; - print ""; + print ""; + print ""; + print ""; print ""; } print "
" . $student['firstname'] . " " . $student['lastname'] . "  " . $student['mnumber'] . "  " . $student['blackboard'] . "" . $student['blackboard'] . "  " . "+1" . "" . "-1" . "
";