I am a beginner to PHP. I have a database set up with songs in it. At the moment there are only 2 songs and one artist. I am trying to query the database by artist. The page seems to work but is only returning one song instead of two. I am calling it like this :
What is the correct way to do this?
<?php
// get artist id from page call
$artist = $_GET['artist'];
// search by artist
$exists = $mysqli->query("SELECT id FROM songs WHERE artist='$artist'") or die($mysqli->error);
// get numeric array out of result
$Songs = mysqli_fetch_array($exists, MYSQLI_NUM);
foreach($Songs as $key){
echo "<a href='http://www.waylostreams.com/login-system/playSong.php?id=$key&user=$user_id'>Listen</a>";
print "<br>";
}
?>
Thanks in advance for any help! Sean