-
Notifications
You must be signed in to change notification settings - Fork 0
/
getSections.php
32 lines (32 loc) · 1.1 KB
/
getSections.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php //Script loaded in index.php made for loading and displaying the select options
require_once "dbconnect.php";
//Connect to db
$conn = @new mysqli($host, $user, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
include_once 'functions.php';
if($_POST['mode'] == 1){
$sql = "SELECT * FROM sekcje WHERE pasID='" . sanitise($_POST['id']) . "'";
}
else{
$sql = "SELECT * FROM sekcje WHERE sesjaID='" . sanitise($_POST['id']) . "'";
}
$result = $conn->query($sql);
$arr = array();
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
if($_POST['mode'] == 1){
$sesjaID = $row["sesjaID"];
$sql = "SELECT * FROM sesje WHERE ID='$sesjaID'";
$query = $conn->query($sql);
$sesja = $query->fetch_assoc();
$row["sesja"] = $sesja;
}
$arr[] = $row;
}
}
$conn -> close();
echo json_encode($arr);
?>