-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery_result.php
executable file
·72 lines (64 loc) · 1.77 KB
/
query_result.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
63
64
65
66
67
68
69
70
71
72
<?php
session_start();
if(!$_SESSION['logged']){
//header("Location: login_page.php");
echo 'logged out '.$_SESSION['username'];
exit;
}
?>
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<head>
<title>Database Project 1</title>
</head>
<body>
<form action="query_result.php" method="post">
Name:<br>
<input type="text" name="name"><br><br>
Department:<br>
<input type="text" name="dept"><br><br>
Title:<br>
<input type="text" name="title"><br><br>
<input type="submit" name="Search" value="Search">
</form>
<?php
echo "CSCE 608 Database Project 1\n";
$link = mysql_connect( $_SESSION['host'], $_SESSION['username'], $_SESSION['password'],$_SESSION['database']);
//echo $_SESSION['host'], $_SESSION['username'], $_SESSION['password'],$_SESSION['database'];
//$link = mysql_connect('database2.cs.tamu.edu', 'tonybest', '11235813', 'tonybest-db1');
// select database
/*
$res = mysql_query("SHOW DATABASES");
while ($row = mysql_fetch_assoc($res)) {
echo $row['Database'] . "<br />\n";
}
*/
// choose tonybest-prof database
$db_selected = mysql_select_db('tonybest-prof', $link);
if (!$db_selected) {
die ('Can\'t use db: ' . mysql_error());
}
echo 'Basic Information';
$name = "'Robert Balog'";
$title = "'Associate Professor'";
$result = mysql_query("SELECT * FROM basic WHERE title='Associate Professor'");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
echo '<table class="w3-table-all w3-hoverable w3-card-4">';
// show table content
while ($row = mysql_fetch_row($result)) {
echo '<tr>';
foreach($row as $field) {
echo '<td>' . htmlspecialchars($field) . '</td>';
}
echo '</tr>';
}
echo '</table>';
mysql_close($link);
?>
</body>
</html>