-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadTracks.php
72 lines (56 loc) · 2.02 KB
/
readTracks.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
<!-- Source: https://www.simplilearn.com/tutorials/php-tutorial/php-crud-operations#how_to_readview_records -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>readAlbumTacksMusicians</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<link rel="stylesheet" href="AlbumTracksMusicians.css">
</head>
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
?>
<!-- <link rel="stylesheet" href="playedWithMiles.css"> -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<?php
require 'credentials.php';
$pdo = new PDO("pgsql:host=$database_host;port=$port;dbname=$database_name;", $database_user, $database_password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
?>
<html>
<header>
<h2>Select album</h2>
<script>
function showAlbum(str) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("albumInfo").innerHTML = this.responseText;
}
};
xmlhttp.open("GET", "getTracks.php?q=" + str, true);
xmlhttp.send();
}
</script>
<?php
require 'credentials.php';
$resultset = $pdo->prepare("SELECT * FROM albums ORDER BY albumtitle");
$resultset->execute();
?>
<select class="btn btn-outline-warning" name="album" onchange="showAlbum(this.value)">
<?php
foreach ($resultset as $row) {
$albumtitle = $row[1];
echo "<option value='$row[0]'>$albumtitle</option>";
}
?>
</select>
</header>
<body>
<div id="albumInfo">
</div>
</body>
</html>