₦airaland Forum

Welcome, Guest: Join Nairaland / LOGIN! / Trending / Recent / New
Stats: 2,118,621 members, 4,587,756 topics. Date: Sunday, 18 November 2018 at 05:27 AM

Trying To Remove Item Fro A Shopping Cart. - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Trying To Remove Item Fro A Shopping Cart. (1240 Views)

How Can I Create A Shopping Cart? / Programming Shopping Cart Issue Wondering How They Do It / Trying To Run Php Project After Installing Wamp Server (2) (3) (4)

(1) (Reply) (Go Down)

Trying To Remove Item Fro A Shopping Cart. by adeyeye546: 10:59am On Oct 09, 2014
<?php
if (isset($_POST['index_to_remove']) && $_POST['index_to_remove'] != ""wink {
// Access the array and run code to remove that array index
// Reomve functionality
$key_to_remove = $_POST['index_to_remove'];// hold array index to that variable and pass it to the local variable

if (count($_SESSION["cart_array"]) <= 1) { // if item greater than one
unset($_SESSION["cart_array"]);
// header("location: cart.php"wink;
} else {
unset($_SESSION["cart_array"]["$key_to_remove"]);//correspond to the cart_item
//sort($_SESSION["cart_array"])
sort($_SESSION["cart_array"]); // sorting of all the multi- dimensional array

};
}
Re: Trying To Remove Item Fro A Shopping Cart. by javadoctor(m): 3:41am On Oct 12, 2014
I don't understand php, but in java you could simply remove the object from a Map
With a key value.

Map <CartItem,Integer>item = new HashMap();
Re: Trying To Remove Item Fro A Shopping Cart. by asalimpo(m): 6:56am On Oct 12, 2014
*Simply use ur hand to remove it and return it to d store shelf!
If ur in a supermarket/mart.

If online use the "remove/delete/save for l8r" button
*

pardon the sakazm but ur question is ripe for misinterpretation.
Re: Trying To Remove Item Fro A Shopping Cart. by Nobody: 9:37am On Oct 12, 2014
javadoctor:
I don't understand php, but in java you could simply remove the object from a Map
With a key value.

Map <CartItem,Integer>item = new HashMap();

True, PHP does the same. @op, just use var_dump($_POST); to get the structure of the array - you can then post it here so we tell you how to remove it - i might not be here, i am hardly here these days. Been building my www.Nairaland.com - and that is taking like all my time.

asalimpo:

*Simply use ur hand to remove it and return it to d store shelf!
If ur in a supermarket/mart.
If online use the "remove/delete/save for l8r" button
*
pardon the sakazm but ur question is ripe for misinterpretation.
That your act is known as thievery and is punishable by life imprisonment.

(1) (Reply)

How Can I Become A Good Web Programmer (esp If I Dont Have Aptech Bucks) / Python Or C++ Which Is Bera / Greatest List Of Freely Available Programming Books

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (0) (1) (2) (3) (4) (5) (6) (7) (8) (9)

Nairaland - Copyright © 2005 - 2018 Oluwaseun Osewa. All rights reserved. See How To Advertise. 33
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.