-
Notifications
You must be signed in to change notification settings - Fork 0
/
c1.php
76 lines (66 loc) · 2.23 KB
/
c1.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
73
74
75
76
<?php
include("data_class.php");
session_start();
if (!isset($_GET['artist_id'])) {
var_dump($_GET['artist_id']);
}
$artist = $_GET['artist_id'];
try {
$obj = new data();
$obj->setconnection();
$query = "SELECT * FROM song WHERE artist_id = :artist_id";
$statement = $obj->connection->prepare($query);
$statement->bindParam(':artist_id', $_SESSION['artist_id'], PDO::PARAM_INT);
$statement->execute();
$songs = $statement->fetchAll(PDO::FETCH_ASSOC);
$obj->connection = null;
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
}
$obj->setconnection();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>View Songs</title>
<link rel="stylesheet" href="style_c1.css">
</head>
<body>
<header>
<h2 class="logo">Cancion</h2>
<nav class="navigation">
<a href="index_p1.html">Home</a>
<a href="#">About</a>
<a href="#">Contact Us</a>
<a href="logout.php">Logout</a> <!-- Add logout link -->
</nav>
</header>
<div id="container">
<h1>My Songs</h1>
<div id="song-list">
<?php if (!empty($songs)): ?>
<?php foreach ($songs as $song): ?>
<div class="song">
<h3><?php echo $song['s_name']; ?></h3>
<p>Mood:
<?php
// Fetch mood name based on mood ID
$query = "SELECT m_name FROM mood WHERE mood_id = :mood_id";
$statement = $obj->connection->prepare($query);
$statement->bindParam(':mood_id', $song['mood_id'], PDO::PARAM_INT);
$statement->execute();
$mood = $statement->fetch(PDO::FETCH_ASSOC);
echo $mood['m_name'];
?>
</p>
</div>
<?php endforeach; ?>
<?php else: ?>
<p>No songs found.</p>
<?php endif; ?>
</div>
</div>
</body>
</html>