Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
link that delete the item from the cart
Old 07-27-2004, 11:15 PM Hard array cart delete question
Experienced Talker

Posts: 34
Trades: 0
I am trying to create a third column in my simple shopping cart that will delete the item from the cart. I tried the line below to achieve this feature:

echo "<td><a href=" . $_SERVER['PHP_SELF'] . "?delete=" .$n. ">Delete</a></td>";

It seems to word with some bugs it will not remove "delete=0"
and it will sometime remove an item but not it's price it will leave 0.00

I thought this would be a easy question to answer any thoughs?? why I am getting this strange errors??

http://www.nucitytech.com/store.php

here is the enter script below:
<?PHP
session_start();
if(!isset($_SESSION['cart'])){
$_SESSION['cart']=array();
}

if(!empty($_GET['delete'])){
unset( $_SESSION['cart'][$_GET['delete']] ) ;
}
$products=array('IBM Laptop', 'Dell Laptop', 'Gateway Desktop', 'Service Contract');
$prices=array(200.00, 300.00, 400.00, 199.99);

echo "<table cellspacing=20 >";
echo "<tr><th>Item Title</th><TH>Price</th></tr>";

for($n=0;$n<count($_SESSION['cart']);$n++){
echo "<tr>";
echo "<td>".$products[$_SESSION['cart'][$n]]."</td>";

echo "<td>".number_format($prices[$_SESSION['cart'][$n]],2)."</td>";

echo "<td><a href=" . $_SERVER['PHP_SELF'] . "?delete=" .$n. ">Delete</a></td>";

echo "</tr>";
$total = $total + $prices[$_SESSION['cart'][$n]];
}


echo "<td><b>TOTAL</td></b>";
echo "<td>".number_format($total,2)."</td>";
echo "<td><a href=store.php>Continue Shopping</a></td>";
echo "</table>";

?>

Last edited by cedtech23; 07-29-2004 at 12:06 AM..
cedtech23 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to link that delete the item from the cart
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.07916 seconds with 12 queries