I have various number of files and database tables including artist
, album
and tracks
.
On the webpage user can choose an artist, an album and then songs or albums to buy.
The desired functionality is: when the user selects to buy the album, all the tracks are added to the shopping cart.
Here is a PHP code chunk with a link for buying an album:
<p>?php
session_start(); <br>
$albumID=$_POST["albumID"]; <br>
echo "<p>Going to buy album $albumID</p>";
echo "<p><a href=\"shopForTracks.php\">Click here to continue</a></p>";
?></p>
I have got also other files with DB queries etc. in them.
There is one to get the artist by letter, another one to get album from artist. Then, a shopping, show basket, show purchases, add to basket and checkout files.
Any help with the problem is greatly appreciated.
Additional code from getTracksByAlbum.php
?php
include ("dbConnect.php");
$albumID=$_GET["id"];
$dbQuery="select id,title from tracks where albumID='$albumID' order by trackNumber
asc";
$dbResult=mysql_query($dbQuery);
echo $albumID."\n";
echo mysql_num_rows($dbResult)."\n";
while ($dbRow=mysql_fetch_array($dbResult)) {
echo $dbRow["id"]."_".$dbRow["title"]."\n";
}
?>
Additional code from showBasket.php
<?php
if (isset($_SESSION["currentUserID"])) {
$dbQuery="select * from basket where paid='N' and userID=".$_SESSION["currentUserID"];
$dbResult=mysql_query($dbQuery);
$numTracks=mysql_num_rows($dbResult);
}
?>
<a href="login.php">Logout <?php echo $_SESSION["currentUser"]; ?></a> |
<a href="shopForTracks.php">Shop for tracks</a> |
<a href="showBasket.php">Show Basket</a> <?php echo "($numTracks)"; ?> |
<a href="checkout.php">Checkout</a> |
<a href="showMyPurchases.php">Show my purchases</a>
<hr>
<?php
$dbQuery="select tracks.title, albums.title, artists.name, basket.id ".
"from basket,tracks,albums,artists ".
"where basket.userID=".$_SESSION["currentUserID"]." ".
"and basket.paid='N' ".
"and basket.trackID=tracks.id ".
"and albums.id=tracks.albumID ".
"and artists.id=tracks.artistID";
$dbResult=mysql_query($dbQuery);
$numTracks=mysql_num_rows($dbResult);
if ($numTracks==0)
echo "<h3>Your basket is empty</h3>";
else {
?>
I'm not sure what other information is needed, I don't fully understand and there's a lot of it. I was originally using this -
$query = mysql_query("SELECT song_id FROM song WHERE album = '".$_POST['albumID']."'")
$_SESSION['ID] = array();
while($album = mysql_fetch_array($query)
{
$_SESSION['basket'][] = $albums['Track_id']
}
to try and work it out - but I'm really lost :(