-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathQuery3.php
More file actions
56 lines (46 loc) · 1.58 KB
/
Copy pathQuery3.php
File metadata and controls
56 lines (46 loc) · 1.58 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
<head><title>All Course Averages</title></head>
<body>
<?php
//open a connection to dbase server
include 'open.php';
// collect the posted value in a variable called $item
$item = $_POST['this_genre'];
// echo some basic header info onto the page
echo "<h2>Average Metrics for a Genre</h2><br>";
// proceed with query only if supplied password is non-empty
if (!empty($item)) {
// call the stored procedure we already defined on dbase
$result = $conn->query("CALL Query3('".$item."');");
if (($result) && ($result->num_rows != 0)) {
echo "<table border=\"2px solid black\">";
// output a row of table headers
echo "<tr>";
// collect an array holding all attribute names in $result
$flist = $result->fetch_fields();
// output the name of each attribute in flist
foreach($flist as $fname){
echo "<td>".$fname->name."</td>";
}
echo "</tr>";
// output a row of table for each row in result, using flist names
// to obtain the appropriate attribute value for each column
foreach($result as $row){
// reset the attribute names array
$flist = $result->fetch_fields();
echo "<tr>";
foreach($flist as $fname){
echo "<td>".$row[$fname->name]."</td>";
}
echo "</tr>";
}
echo "</table>";
} else {
echo "No songs with this genre";
}
} else {
echo "No genre provided <br>";
}
// close the connection opened by open.php
$conn->close();
?>
</body>