473,470 Members | 1,906 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Product ID same, Quantity not increasing

1 New Member
When I add the product twice, it keep displaying in a new line, with new quantity. I want the quantity to update. here's the code:

Expand|Select|Wrap|Line Numbers
  1. <?
  2. include "functions.php";
  3. if(!$_SESSION['logged']){die();}
  4. $_POST['taxes']=str_replace('undefined,','',$_POST['taxes']);
  5. if(empty($_SESSION['products']))$_SESSION['products']=array();
  6.  
  7.     if($_POST['action']=='add'){
  8.     $_POST[$qty]=str_replace(',','.',$_POST[$qty]);
  9.         $_SESSION['products'][]=$_POST;
  10.     }
  11.     if($_POST['action']=='delete'){
  12.         unset($_SESSION['products'][$_POST['id']]);
  13.     }    
  14.  
  15.     if($_POST['action']=='update'){
  16.         if($_POST['rule']==0)$_SESSION['products'][$_POST['id']]['qty']-=1;
  17.         if($_POST['rule']==1)$_SESSION['products'][$_POST['id']]['qty']+=1;
  18.     }
  19. ?>
  20.  
Feb 10 '14 #1
1 1155
Dormilich
8,658 Recognized Expert Moderator Expert
I don’t think your posted code has anything to do with your problem.
Feb 11 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Nicolae Fieraru | last post by:
Hi All I have a form, with a few input boxes (number of input boxes can vary). Each input box has a name such as in1, in3, in7, etc (their names can be in any order, although increasing). I...
2
by: Gary Vidal | last post by:
I have a shopping cart webpage that shows a product and the Quantity they would like to order: When you click the link I want to take the quantity that they entered in the textbox and post that to...
9
by: Rob Meade | last post by:
Hi all, Ok - so I've got the array thing going on, and the session thing going on, and up until now its all been ok. I've got my view basket page which is displaying 3 rows (as an example) - I...
3
by: Newbie | last post by:
I have two different levels of people who want to see my production report. We get orders which each call for one of five products. One level wants to see a spreadsheet type report with six...
1
by: ktang3227 | last post by:
Hi all, I have a table which list all the different product# and quantity of the product in each row. But for some reason, some of the product splites into 2 rows. For example; Product A has...
5
by: goldstar | last post by:
hello all. Another problem, since i have joined all i have been doing is asking for help. i need to repay all these favours!!! I currently have an order form, and a product form, Scenario: if...
4
by: bnashenas1984 | last post by:
Hi everyone I'm sure there are many open source Ecommerce scripts out there but because of some reasons i'm building my own. I'm having a problem with reserving products. Here's what I need :...
4
by: phpTeryoh | last post by:
Im completely new in php and in the process of trying to develop my project Im getting a problem in writting a code that can increase the quantity of the record by the value inserted in the textbox...
8
by: parul sinha | last post by:
whenever i am entering the quantity of item i got error undefined offset. i am sending my full code:- this is so.php for shopping cart:- <html> <center><table width="100%" height="300">...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.