Jump to content

Recommended Posts

Hi I have a shopping cart that displays the products that a customer buys. When a customer buys a product only one is added to the cart. I would like a way of updateing the quantity in the cart. The code for the cart is below. I would be grateful for any suggestions?
ps I'm new to php.

<?php
include ("Products_inc.php");

//call to stylesheet on include file
HeaderAndStylesheet();

$query= "SELECT*FROM cart WHERE Username='$Username'";
$result=mysql_query($query);
$num=mysql_num_rows($result);

if ($num ==0)
{
echo "The database contains no contacts yet";
}
else
{
echo "<b><centre> Cart</centre></b><br><br>";
//echo "$Full_name";
?>

<table border ="1" cell spaceing= "2" cellpadding= "2">
<tr>
<th><font face= "Arial, Helvetica, sans-serif"> order id</font></th>
<th><font face= "Arial, Helvetica, sans-serif"> Product Name</font></th>
<th><font face= "Arial, Helvetica, sans-serif"> Username</font></th>
<th><font face= "Arial, Helvetica, sans-serif"> Product Description</font></th>
<th><font face= "Arial, Helvetica, sans-serif"> Price</font></th>
<th><font face= "Arial, Helvetica, sans-serif"> Quantity</font></th>
<th><font face= "Arial, Helvetica, sans-serif"> Delete</font></th>
</tr>
<?
$i=0;
while ($i<$num)
{
$order_id=mysql_result($result, $i, "order_id");
$Name=mysql_result($result, $i, "Name");
$Username=mysql_result($result, $i, "Username");
$Description=mysql_result($result, $i, "Description");
$Price=mysql_result($result, $i, "Price");
$Quantity=mysql_result($result, $i, "Quantity");
?>
<tr>
<td width=100><font face="Arial,Helvetica, sans-serif"><? echo $order_id?></font></td>
<td width=100><font face="Arial,Helvetica, sans-serif"><? echo $Name?></font></td>
<td width=100><font face="Arial,Helvetica, sans-serif"><? echo $Username?></font></td>
<td width=150><font face="Arial,Helvetica, sans-serif"><? echo $Description?></font></td>
<td width=100><font face="Arial,Helvetica, sans-serif"><? echo "£$Price"?></font></td>
<td><font face="Arial,Helvetica, sans-serif"><? echo $Quantity?></font></td>

<td><font face="Arial,Helvetica, sans-serif">
<?
echo "<form action=\"delete_from_cart.php\" method=\"post\">";
echo "<input type=\"submit\" value=\"Delete\">";
echo "<input type=\"hidden\" name =\"order_id\" value=$order_id>";
echo "<input type=\"hidden\" name =\"Username\" value=$Username>";
echo "</form>";
?>
</td>
</tr>
<?
$i++;
}
echo "</table>";
}
echo "<form action=\"display_product.php\" method=\"post\">";
echo "<input type=\"submit\" value=\"Continue shopping\">";
echo "<input type=\"hidden\" name =\"Username\" value=$Username>";
echo "<input type=\"hidden\" name =\"Full_name\" value=$Full_name>";
echo "</form><br>";

echo "<form action=\"check_out.php\" method=\"post\">";
echo "<input type=\"submit\" value=\"Go to check out\">";
echo "<input type=\"hidden\" name =\"Username\" value=$Username>";
echo "<input type=\"hidden\" name =\"Full_name\" value=$Full_name>";
echo "</form>";
?>
Link to comment
https://forums.phpfreaks.com/topic/12680-update-help/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.