I am trying to make a cd website thing for my uni course and i am trying to make the shopping cart page at present. However, i have come across a strange (to me anyway) problem.
I have the following code but when opening the page it doesnt display anything at all, not even the echo commands at the very beginning which i think is strange. What i am trying to accomplish with this page is to show all the details of a cd where the cd id in the stock table is the same as in the shopping cart, therefore showing the information of the cd in the shopping cart.
I am wondering if any of you could help
Thank you
Here is my code:
Code: Select all
<?php
echo "stage1";
$host = "localhost";
$user = "10241976";
$password = "*******";
$database = "10241976";
//connect to MySQL
$connect = mysql_connect($host, $user, $password )
or die("Hey loser, check your server connection.");
//make sure we're using the right database
mysql_select_db($database);
echo "stage1";
// set up the SQL query
$query = "SELECT * FROM shoppingcart";
$query2 = "SELECT * FROM stocktable WHERE stocktable.disc_id = shoppingcart.disc_id";
// execute the query
$results = mysql_query($query)
or die(mysql_error());
$results2 = mysql_query($query2)
or die(mysql_error());
echo "stage2";
// count the number of rows that are selected from the table
$numrow = mysql_num_rows($results);
?>
<html>
<head><title>Chris' Rainforest</title>
<link rel="stylesheet" type="text/css" href="master.css"/>
</head>
<body>
Welcome to Chris' Rainforest
Your cart
</br>
<table border="1" align = "center">
<tr id="list">
<td><b>Disc id</b>
<td><b>Album Title</b>
<td><b>quantity</b>
<td><b>price</b>
</tr>
<?php
$count = 0;
while ($count < $numrow)
{
echo "<tr>";
$row = mysql_fetch_array($results2);
extract($row);
// send the values to the browser as a row in a html table
echo "<td>";
echo "<p align='right'>".$disc_id."</a>";
echo "</td>";
echo "<td>";
echo "<p align='right'>".$album."</a>";
echo "</td>";
echo "<td>";
echo "<p align='right'>".$quantity."</a>";
echo "</td>";
echo "<td>";
echo "<p align='right'>".$price."</a>";
echo "</td>"l
echo "<td>";
echo "<a href='deletefromcart.php?disc_id=".$disc_id."'>Delete from cart</a>";
echo "</tr>";
echo "</tr id='list'>";
$count = $count + 1;
}
?>
</table>
</body>
</html>