-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetNumGroups.php
More file actions
executable file
·24 lines (16 loc) · 856 Bytes
/
getNumGroups.php
File metadata and controls
executable file
·24 lines (16 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
$authorID = $_REQUEST['authorID'];
$db = new PDO('mysql:host=localhost;dbname=group_maker', 'root', 'password',array(PDO::ATTR_EMULATE_PREPARES => false,PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); //From: http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers
$stmt = $db->prepare("SELECT * FROM classes where authorId=?"); //prepare insert
$stmt->execute(array($authorID));
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$areGroupsMade = $rows[0]['groupsMade'];
$classID = $rows[0]['classId'];
if($areGroupsMade == 1){
$stmt1 = $db->prepare("SELECT * FROM students where class=? ORDER BY groupNumber ASC"); //prepare insert
$stmt1->execute(array($classID));
$rows = $stmt1->fetchAll(PDO::FETCH_ASSOC);
$numGroups = $rows[sizeOf($rows) - 1]['groupNumber'];
echo $numGroups;
}
?>