can someone help to add new products and increase the quantity of the product when pressing the + button, but it works for [-]
<?php
include "./php/connection.php";
function products () {
$query = "SELECT * FROM product";
if (@mysql_num_rows($query)==0) {
echo "There are no products to display!";
}
else {
while ($query_row = mysql_fetch_array($query)) {
print
"<div class='product'>" .
"<img class='img' src=". $row["Image"]." alt='phone' width='100' height='150' />" .
"<p class='name'>".$row["Name"]."</p>".
"<p class='price'>£". $row["Price"] ."</p>".
"<p><a href='./cart.php?ProductID=". $row["ProductID"]."' class='myButton'>More Info</a></p>".
"</div>";
}
}
}
if (isset($_GET['ProductID'])) {
$quantity = mysql_query('SELECT * FROM product WHERE ProductID = ' .$_GET["ProductID"]);
while ($quantity_row = mysql_fetch_array($quantity)) {
if ($quantity_row["Quantity"]!=@$_SESSION["cart_".$_GET["ProductID"]]) {
@$_SESSION["cart_".$_GET["ProductID"]]+="1";
}
}
}
if (isset($_GET["remove"])) {
$_SESSION["cart_".$_GET["remove"]]--;
header("Location: ./cart.php"); # Go back to the login pages
}
if (isset($_GET["delete"])) {
$_SESSION["cart_".$_GET["delete"]]="0";
header("Location: ./cart.php"); # Go back to the login pages
}
function paypal_items() {
$num = 0;
foreach($_SESSION as $name => $value) {
if ($value!=0) {
if (substr($name, 0, 5) == "cart_") {
$productid = substr($name, 5, (strlen($name)-5));
$query = mysql_query('SELECT ProductID, Manufacturer, model, Price FROM product WHERE ProductID =' .$productid);
while ($query_row = @mysql_fetch_array($query)) {
$num++;
echo '<input type="hidden" name="item_number_'.$num.'" value="'.$productid.'">';
echo '<input type="hidden" name="item_name_'.$num.'" value="'.$query_row['Name'].'">';
echo '<input type="hidden" name="amount_'.$num.'" value="'.$query_row['Price'].'">';
echo '<input type="hidden" name="shpping_'.$num.'" value="0">';
echo '<input type="hidden" name="shpping_'.$num.'" value="0">';
echo '<input type="hidden" name="quantity_'.$num.'" value="'.$value.'">';
}
}
}
}
}
function cart () {
print
"<table id='producttable' border='1'>".
"<tr>".
"<td class='td top'>Delete</td>".
"<td class='td top'>Product Name</td>".
"<td class='td top'>Quantity</td>".
"<td class='td top'>Price</td>".
"<td class='td top'>Sub Total</td>".
"</tr>";
foreach($_SESSION as $name => $value) {
if ($value>0) {
if (substr($name, 0, 5) == "cart_") {
$productid = substr($name, 5, (strlen($name)-5));
$query = mysql_query('SELECT * FROM product WHERE ProductID =' .$productid);
while ($query_row = @mysql_fetch_array($query)) {
$sub = $query_row["Price"] * $value;
print
"<tr>".
"<td class='td'><a href='./cart.php?delete=".$productid."'> [Delete] </a></td>".
"<td class='td'>".$query_row["Manufacturer"]."</td>".
"<td class='td'>".$value."</td>".
"<td class='td'><a href='./cart.php?ProductID=".$productid."'> [+] </a>£".$query_row["Price"]."<a href='./cart.php?remove=".$productid."'> [-] </a></td>".
"<td class='td'>£".$sub."</td>".
"</tr>";
}
}
@$total += $sub;
}
}
if (@$total==0) {
echo "<p>Your basket is empty</p>";
}
else {
echo @" Total: £" .$total;
?>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="kamran193@hotmail.co.uk">
<?php
paypal_items();
?>
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="amount" value="<?php echo $total; ?>">
<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but03.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
<?php
}
echo "</table>";
}
echo cart();
echo products();
?>