Hi im workin on a HTML/php shopping basket.
The shopping basket like all 'shopping baskets' :rolleyes: online stores a list of products the customers buying. Now ive got the database to store product info and the webpage to recall this information and display it. However on this one particular page im having trouble displaying much of anything at all. :mad:
The problem im having is im not sure if any results are being returned. Ok a customer selects a product... views its details... decides they want one... clicks 'Add to Basket' all the details are then sent from getproduct to modcart via:
<form method="POST" action="modcart.php?action=add">
and then its "SUPPOSED" to take you to a page where it displays the product info being placed into the basket (behind the scenes the product selected is being stored in the database in a table called carttemp)
if (isset($POST['qty'])) {
$qty = $POST['qty'];
}
if (isset($POST['product_id'])) {
$product_id = $POST['product_id'];
}
if (isset($POST['modified_hidden'])) {
$modified_hidden = $POST['modified_hidden'];
}
if (isset($POST['modified_quan'])) {
$modified_quan = $POST['modified_quan'];
}
$sess = session_id();
$action = $_REQUEST['action'];
switch ($action) {
case "add":
$query = "INSERT INTO carttemp (
carttemp_sess,
carttemp_quan,
carttemp_prodnum)
VALUES ('$sess','$qty','$prodnum')";
$message = "<div align=\"center\"><strong>Item
added.</strong></div>";
break;
case "change":
$query = "UPDATE carttemp
SET carttemp_quan = '$modified_quan'
WHERE carttemp_hidden = '$modified_hidden'";
$message = "<div align='center'><strong>Quantity
changed.</strong></div>";
break;
case "delete":
$query = "DELETE FROM carttemp
WHERE carttemp_hidden = '$modified_hidden'";
$message = "<div align='center'><strong>Item
deleted.</strong></div>";
break;
case "empty":
$query = "DELETE FROM carttemp WHERE carttemp_sess = '$sess'";
$message = "<div align='center'><strong>Cart
emptied.</strong></div>";
break;
}
but i think there must be a problem with storing the information bcoz it wont display the products stored as part of cart.php
//display number of products in cart
$query = "SELECT * FROM carttemp WHERE carttemp_sess = '$sessid'";
$results = mysql_query($query)
or die (mysql_query());
$rows = mysql_num_rows($results);
echo $rows;
$total = 0;
while ($row = mysql_fetch_array($results)) {
echo "<tr>";
extract($row);
$prod = "SELECT FROM products " .
"WHERE product_id='$carttemp_prodnum'";
$prod2 = mysql_query($prod);
if(mysql_num_rows($prod2))
{
$prod3 = mysql_fetch_array($prod2);
extract($prod3);
}
echo "<td>
<form method=\"POST\" action=\"modcart.php?action=change\">
<input type=\"hidden\" name=\"modified_hidden\"
value=\"$carttemp_hidden\">
<input type=\"text\" name=\"modified_quan\" size=\"2\"
value=\"$carttemp_quan\">";
echo "</td>";
echo "<td>";
echo "<a href=\"getprod.php?prodid=" . $product_id . "\">";
echo "<img src=\"$product_pic\"></a></td>";
echo "<td>";
echo "<a href=\"getprod.php?prodid=" . $product_id . "\">";
echo $product_title;
echo "</a></td>";
echo "<td align=\"right\">";
echo $product_price;
echo "</td>";
echo "<td align=\"right\">";
//get extended price
$extprice = number_format($product_price $carttemp_quan, 2);
echo $extprice;
echo "</td>";
echo "<td>";
echo "<input type=\"submit\" name=\"Submit\"
value=\"Change Qty\">
</form></td>";
echo "<td>";
echo "<form method=\"POST\" action=\"modcart.php?action=delete\">
<input type=\"hidden\" name=\"modified_hidden\"
value=\"$carttemp_hidden\">";
echo "<input type=\"submit\" name=\"Submit\"
value=\"Delete Item\">
</form></td>";
echo "</tr>";
//add extended price to total
$total = $extprice + $total;
}
Ive wrecked my brain for three days trying to figour it out and nothing. :queasy: And all it displays on the screen are blank spaces where the product title and price is supposed to be.
Can anyone Help? 😕