-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
62 lines (45 loc) · 1013 Bytes
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
*
*/
class db2_connector{
//Free Spaces
$freeSpces;
//DB Information
$servername = "localhost";
$username = "root";
$password = "";
$db_name = "";
function __construct(argument)
{
//
}
function db2_connect(){
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}else{
return $conn;
}
echo "Connected successfully";
}
function db2_close(connection){
connection->close();
}
function getFreeSpaces(connection){
$tableName = "generalInfo";
$sql = "SELECT freeSpces FROM " . $tableName;
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["freeSpces"];
}
} else {
echo "0 results";
}
}
}
?>