forked from cwerner6/databases-final-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tableshow.php
executable file
·55 lines (46 loc) · 1.37 KB
/
tableshow.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
<?php
function show_artists($conn) {
$sql = "SELECT artist_id, artist_name, label_name FROM artist, record_label WHERE artist.label_id = record_label.label_id";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo '<table border>';
echo '<thead><tr>';
echo '<th>'."ID".'</th>'.'<th>'."Name".'</th>'.'<th>'."Record Label".'</th>';
echo '</tr></thead>';
echo '<tbody>';
while($row = $result->fetch_assoc()) {
echo '<tr>';
echo "<td>" . $row["artist_id"]. "</td>";
echo "<td>" . $row["artist_name"]. "</td>";
echo "<td>" . $row["label_name"]. "</td>";
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
} else {
echo "0 results";
}
}
function show_albums($conn) {
$sql = "SELECT album_id, album_name, genre_name FROM album, genre WHERE artist.genre_id = genre.genre_id";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo '<table border>';
echo '<thead><tr>';
echo '<th>'."ID".'</th>'.'<th>'."Name".'</th>'.'<th>'."Record Label".'</th>';
echo '</tr></thead>';
echo '<tbody>';
while($row = $result->fetch_assoc()) {
echo '<tr>';
echo "<td>" . $row["album_id"]. "</td>";
echo "<td>" . $row["album_name"]. "</td>";
echo "<td>" . $row["genre_name"]. "</td>";
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
} else {
echo "0 results";
}
}
?>