-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.php
More file actions
81 lines (67 loc) · 1.64 KB
/
database.php
File metadata and controls
81 lines (67 loc) · 1.64 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
$hostname = "localhost";
$username = "root";
$password = "sesame";
$db_name = "projectDB";
$mysqli = new mysqli($hostname, $username, $password, $db_name);
if ($mysqli->connect_errno){
die('Unable to connect to DB');
}else{
echo "Connected successfully";
}
/*Attempts to query the database,
couldn't get to work properly despite successful connect so we mostly used html since the php pages kept crashing
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
$sql = 'SELECT * FROM Course;';
$result = $mysqli->query($sql);
$num_rows = $result->num_rows;
for ($i = 0; $i < $num_rows; ++$i) {
$row = $result->fetch_array(MYSQLI_ASSOC);
echo $row['CourseName']);
}
$sql = 'SELECT * FROM Professor;';
$result = $mysqli->query($sql);
$num_rows = $result->num_rows;
for ($i = 0; $i < $num_rows; ++$i) {
$row = $result->fetch_array(MYSQLI_ASSOC);
echo $row['LastName']);
}
$sql = 'SELECT * FROM Section;';
$result = $mysqli->query($sql);
$num_rows = $result->num_rows;
for ($i = 0; $i < $num_rows; ++$i) {
$row = $result->fetch_array(MYSQLI_ASSOC);
echo $row['SectionNum']);
}
$sql = 'SELECT * FROM Login;';
$result = $mysqli->query($sql);
$num_rows = $result->num_rows;
for ($i = 0; $i < $num_rows; ++$i) {
$row = $result->fetch_array(MYSQLI_ASSOC);
echo $row['UserName']);
}
?>
#Attempt for password system
<?php
if (empty($UserName) || empty($Password){
exit();
}else(
$sql = "SELECT UserName from Login where UserName=?";
$stmt = mysqli_stmt_init($mysqli);
if () {
exit();
}else{
}
)
?>
</body>
</html>
*/
$mysqli->close();
?>