PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$cardId=$_SESSION['cartId'];
$delCart=$_GET['delCart'];
// Not working- start //
if($delCart=="delCart")
{
$delId=$_GET['delId'];
unset($cardId[$hiddel]);
}
// Not working - end//
$uniqueCart=array_unique($cardId);
$arrayCount=array_count_values($cardId);
foreach($uniqueCart as $cardIds)
{
//code for fetch data from database using $cardIds.
//displaying the values.
<td align='center'><a href='cart.php?delCart=delCart&delId=$cardIds'>DELETE</a></td> //for sending value to delete.
}
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Yes, that's what i pointed out, in my last reply.
for adding to the cart i am using,
[syntax="html"]<input type='hidden' name='cartId' value='$r[prodId]'><input type='submit' name='dowCart' value='Add to cart'>
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
kpraman wrote:I want to delete the item in shopping cart. Its not working. Can anyone tell me, how to do?
In your example you are making a copy of the session variable containing the cart and then deleting from it. That will not change the array in the session. You need to either assign back or operate directly on the session var.