How it works: Clicking on the album will take you to “album.php?id=#”
//initialize some vars
$albumID = '';
//check what photo we are looking for
if(isset($_GET['id'])){
$albumID = mysql_real_escape_string($_GET['id']);
Query:
$sql = mysql_query(
SELECT *
FROM albums
JOIN songs
ON albums.performer=songs.performer
WHERE albums.albumID='albumID'
);
What I was trying to accomplish is have it display the album and tracklist. Does anybody know how I should fix this problem? Thank you.
Start by placing your query in a string:
Then, if an album is present, add to that query:
At this point, we can go ahead and run the query:
We run the query, using
mysql_query, and pass its results into the$resultvariable. If anything goes wrong, like an error in our query, our program willdie, and the most recentmysql_error()will be printed to the screen.With our
$resultvariable, we can now cycle through and print the results:Note that
columnAis a placeholder, where you should actually write the column name(s) you have stored in your database.