I need help to connect to my database. My goal is to make it look like in the picture, but my php knowledge only goes so far. I want it to make more efficent, so when a new songs comes out i only need to add it in the data base. my goal
<?php foreach($songs as $song): ?>
<div class="col default-6 large-4">
<?php echo "<img src='/uploads/{$song['cover']}'>"; ?>
<span><?php echo $song["title"];?></span>
<a href="<?php echo $song["spotify"]?>">
<img src="./assets/img/index/spotify_4096_black.png" alt="Spotify">
</a>
<a href="<?php echo $song["apple-music"]?>">
<img src="./assets/img/index/apple_music_logo_icon_145488.png" alt="Apple Music">
</a>
<a href="<?php echo $song["youtube"]?>">
<img src="./assets/img/index/youtube.png" alt="YouTube">
</a>
<a href="<?php echo $song["soundcloud"]?>">
<img src="./assets/img/index/soundcloud.png" alt="Soundcloud">
</a>
<a title="<?= $data["title"]; ?>" href="<?= $file ?>" class="<?php active($file);?>"><?= $data["name"]; ?> </a>
</li>
<?php endforeach; ?>
On my website comes this error:
Warning: Undefined variable $songs in /homepages/26/d999865336/htdocs/workshop/releases.php on line 131
Warning: foreach() argument must be of type array|object, null given in /homepages/26/d999865336/htdocs/workshop/releases.php on line 131
user25056091 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.