Hi, ive a piece of code which i have to modify so that the output is modified to appear as a table. The code is to do with buying songs etc, the output is
Beatles Abbey Road Come Togeher
Something
Revolver Taxman
Yellow Submarine
Eleanor Rigby
Oasis Be Here Now Stand By Me
All Around The World
as you can see it is to display the artist then the album and songs that the user has selected, the albums and songs are to be alphabtical. i have no idea how to do this any help please.
<?php
session_start();
include ("dbConnect.php");
if (!isset($_SESSION["currentUserID"]))
header("Location: login.php");
if ($_POST["action"]=="deleteFromBasket") {
$dbQuery="delete from basket where id=".$_POST["purchaseID"];
$dbResult=mysql_query($dbQuery);
}
?>
<html>
<head>
<title>mp3 Shop</title>
<style type="text/css">
th, td { font-family: verdana; font-size:10pt; text-align:left }
table { border-collapse:collapse }
th { padding:5px }
td { border:solid 1px #000; padding:5px; }
td.noborder { border:0px; font-weight:bold; text-align:right; padding:5px }
.inline { display:inline; }
.right { text-align:right; }
.bold { font-weight:bold; }
</style>
</head>
<body>
<h1>mp3 Shop</h1>
<hr>
<?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='Y' ".
"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>You have not made any purchases</h3>";
else {
?>
<h2>Your Purchase History</h2>
<table style="margin-left:15px">
<tr><th>Title</th><th>Artist</th><th>Album</th></tr>
<?php
$numTracks=mysql_num_rows($dbResult);
while ($dbRow=mysql_fetch_array($dbResult)) {
echo "<tr><td>$dbRow[0]</td><td>$dbRow[2]</td><td>$dbRow[1]</td></tr>";
}
}
?>
</table>
</body>
</html>