-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
60 lines (42 loc) · 1.53 KB
/
index.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
<?php
include('config/db_connect.php');
//write query for all songs
$sql = 'SELECT nickname, songs, id FROM songs ORDER BY created_at';
//make query & get result
$result = mysqli_query($conn, $sql);
//fetch the resulting rows as an array
$charts = mysqli_fetch_all($result, MYSQLI_ASSOC);
//free result from memory
mysqli_free_result($result);
//close connection
mysqli_close($conn);
//explode(',', $charts[0]['songs']);
?>
<!DOCTYPE html>
<html lang="en">
<?php include('templates/header.php') ?>
<h4 class="center grey-text">Hits!</h4>
<div class="container">
<div class="row">
<?php foreach($charts as $chart): ?>
<div class="col s6 md3">
<div class="card">
<img src="img/radio.png" alt="radio" class="song">
<div class="card-content center">
<h6><?php echo htmlspecialchars($chart['nickname']); ?></h6>
<ul>
<?php foreach(explode(',', $chart['songs']) as $sng): ?>
<li><?php echo htmlspecialchars($sng); ?></li>
<?php endforeach; ?>
</ul>
</div>
<div class="card-action right-align">
<a href="details.php?id=<?php echo $chart['id']?>" class="brand-text">more info</a>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php include('templates/footer.php') ?>
</html>