Hi
I hope someone out there can help me.
Im developing a sessionbased shoppingcart. When adding something in
the cxart I do:
session_start() ;
$_SESSION["cart"][]=array("artnr" => $_GET["artnr"],
"nr" => $_GET["nr"],
"price" => $_GET["price"],
"colors" => $_GET["colors"]
);
It works fine. BUT, when I want to remove one of these element in the
cart: how should I proceed? I have read many post but dindnt find one
suitable to my case.
Thanks
Paolo 5 2701
*** paolo wrote/escribió (19 May 2004 04:28:10 -0700): $_SESSION["cart"][]=array(...); It works fine. BUT, when I want to remove one of these element in the cart: how should I proceed? I have read many post but dindnt find one suitable to my case.
Maybe you could provide an index number for the array:
$_SESSION['cart_top']++;
$_SESSION["cart"][$_SESSION['cart_top']]=array(...);
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
unset($_SESSION['cart'][$some_index]);
to be able to get the correct value for $some_index, an idea is to have each
item in your store be assigned an ID from the database that they're in
(supposing you're using one). Then have $some_index be that ID, so that you
can remove the right item from the cart when you want to.
- JP
"paolo" <pa*********@ho tmail.com> wrote in message
news:f9******** *************** **@posting.goog le.com... Hi
I hope someone out there can help me.
Im developing a sessionbased shoppingcart. When adding something in the cxart I do: session_start() ; $_SESSION["cart"][]=array("artnr" => $_GET["artnr"], "nr" => $_GET["nr"], "price" => $_GET["price"], "colors" => $_GET["colors"] ); It works fine. BUT, when I want to remove one of these element in the cart: how should I proceed? I have read many post but dindnt find one suitable to my case.
Thanks
Paolo
Yes, buit what do you do when you iterate?
Say that $_SESSION['cart_top'] has become 5.
Now you need to remove $_SESSION["cart"][3]
Then you do unset($_SESSION["cart"][3]) I guess?
What happens now? cart_top is still 5. So when you iterate
$_SESSION["cart"][3] will fail, doesnt it?
Paolo
IS not the same problem with your solution?
I do like this now:
$_SESSION["counter"]==null ? $_SESSION["counter"]=0 :
$_SESSION["counter"]++;
$_SESSION["cart"][$_SESSION["counter"]]=array(
"artnr" => $_GET["nr"],
"price" => $_GET["price"],
"colors" => $_GET["colors"]
);
*** paolooracle wrote/escribió (Wed, 19 May 2004 15:04:07 GMT): What happens now? cart_top is still 5. So when you iterate $_SESSION["cart"][3] will fail, doesnt it?
foreach($_SESSI ON["cart"] as $index){
...
}
--
--
-- Álvaro G. Vicario - Burgos, Spain
-- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David Lozzi |
last post by:
Hello All,
I am having an issue with thus far one computer on my client's web site. If the user loads the shopping cart and then closes all browser windows, then opens them back up, goes back to the site, the shopping cart information is there! The shopping cart info is only loaded into a session variable! There are no cookies on the site to...
|
by: Seth |
last post by:
I have noticed that the id of my session object changes
when I switch from a non-secure to a secure connection.
What I'm trying to do:
I have a cookie that is built on the non-secure side of
things. What I need to do is to switch to a secure
connection and then later on while still in that secure
connection delete the cookie that was...
|
by: Joe Molloy |
last post by:
Hi,
This isn't a mission critical question but I thought I'dl throw it out there
for your feedback as it's a bit curious.
I have developed a shopping cart for an application I'm working on which is
loosely based on the e-commerce example in the quickstarts tutorial.
In the cart display I have provided functionality so that when a user...
|
by: Adil Akram |
last post by:
I have created a site shopping cart in ASP.net.
I am using ASP session object's SessionID on non SSL connection to track
session.
While adding products to cart DB I insert product and SessionID in table.
All products and cart status pages are on non SSL connection.
On checkout to get secure user information I shifted connection to SSL but...
|
by: TRB_NV |
last post by:
I'm losing information from my Session when I change pages or start the same
page over again. I simplified the code so the example is really clear. The
sample code that follows is supposed to generate a random number and put it
into an Array and store it in the Session variable and then when it runs the
next time, generate another random...
| |
by: KevinGravelle |
last post by:
What is wrong with this picture?
I'm trying to set my shopping cart text on my home page using the
following function that is executed when the class is constructed:
protected string fnGetShoppingCartText()
{
if (Session != null)
{
ArrayList cart = (ArrayList)Session;
|
by: TRB_NV |
last post by:
I'd been using an Access database based shopping cart, but wanted to change
it so that it would use session variables. I have a form that's submitted
to a page called addtocart.asp that contains the following information:
intProdID -- ProductID
strProdName -- Product Name
intQuant -- Quantity
intProdPrice -- Price
productType -- Type of...
|
by: Nick Gilbert |
last post by:
Hi,
Is it possible to access the Session of an arbitary user from an aspx page?
On an e-commerce site, I am notified of payment success via a callback
from the payment server to an ASPX page on my system. I would like to be
able to access the session of the user that submitted the order, and
clear their basket. I don't really want to...
|
by: chrism |
last post by:
Thanks a lot for the detailed reply, Jerry.
As I was trying out your suggestion, I noticed a flaw in my code:
Towards the top of the page, before any processing, I set:
$cart = $_SESSION;
So, I think the page is grabbing the previous values of the session
values and using them, not resetting them according to what the user
enters into the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |