forked from earist/3.kodutoo-III-ruhm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_functions.php
43 lines (32 loc) · 1.13 KB
/
edit_functions.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
37
38
39
40
41
42
43
<?php
require_once("../config_global.php");
$database = "if15_Harri_3";
function getEditData($edit_id){
$mysqli = new mysqli($GLOBALS["servername"], $GLOBALS["server_username"], $GLOBALS["server_password"], $GLOBALS["database"]);
$stmt = $mysqli->prepare("SELECT exam, grade, mistakes FROM eksam WHERE id=? AND deleted IS NULL");
$stmt->bind_param("i", $edit_id); //bind_param asendab küsimärgid
$stmt->bind_result($exam, $grade, $mistakes);
$stmt->execute();
$review = new StdClass();
if($stmt->fetch()){
//sain
$review->exam =$exam;
$review->grade=$grade;
$review->mistakes=$mistakes;
}else{
header("Location:data.php");
}
return $review;
$stmt->close();
$mysqli->close();
}
function updateReview($id, $exam, $grade, $mistakes){
$mysqli = new mysqli($GLOBALS["servername"], $GLOBALS["server_username"], $GLOBALS["server_password"], $GLOBALS["database"]);
$stmt = $mysqli->prepare("UPDATE eksam SET exam=?, grade=?, mistakes=? WHERE id=?");
$stmt->bind_param("sssi", $exam, $grade, $mistakes, $id);
if($stmt->execute()){
}
$stmt->close();
$mysqli->close();
}
?>