-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrate_db.php
36 lines (31 loc) · 960 Bytes
/
rate_db.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
33
34
35
36
<?php
require_once ('db.php');
function add_new_rating ($classID, $rate, $comment, $date)
{
$sql = 'insert into rate (classID, rate, comment, date) values (?, ?, ?, ?)';
$conn = get_connection();
$stm = $conn->prepare($sql);
$stm->bind_param('sdss', $classID, $rate, $comment, $date);
$stm->execute();
if ($stm->affected_rows == 1) {
return $classID;
}
return 0;
}
function get_rating_by_classID($classID)
{
$sql = 'select * from rate where classID = ?';
$conn = get_connection();
$stm = $conn->prepare($sql);
$stm->bind_param('s', $classID);
$stm->execute();
if ($stm->execute() == 1) {
$result = $stm->get_result();
$data = $result->fetch_assoc();
if ($data != null) {
return $data;
}
}
return 0;
}
?>