Hi, so ive various number of files and database tables including artist, album and tracks. On the webpage user's can choose and artist, an album then songs or the album to buy. However ive to write code so that when the user selects to buy the album all the tracks are added to the shopping cart.

The file ive to add the code to only has the following in it:



   echo "<p>Going to buy album $albumID</p>";
   echo "<p><a href=\"shopForTracks.php\">Click here to continue</a></p>";


I do have other files with dbquerys etc in it, theres one to get the artist by letter, get album from artist. A shopping, show basket, show purchases,add to basket and checkout files. Not sure if that helps.

Recommended Answers

All 2 Replies

Do do this you will need to add and extra column in the table for the tracks entitiles "album". And then you would need the following PHP/MySQL query or something like it:

$query = mysql_query("SELECT song_id FROM song WHERE album = '".$_POST['album']."'")

$_SESSION['cart_items'] = array();

while($album = mysql_fetch_array($query)
    $_SESSION['cart_items'][] = $album['song_id']
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.