Jump to content

updating a value in a multidimensional array


Giddy Rob

Recommended Posts

Hi,

 

i am creating a shopping cart and am wondering how I can update a value in the array? The reason I want to do this is for the quantity of items the customer would like to buy.

 

As you can see from the code:

$disp="SELECT id, name, description, priceforpaypal, colour FROM portfolio WHERE id='{$_POST['id']}'";
$display=mysql_query($disp);
$displays=mysql_fetch_array($display);

if(empty($_SESSION['items'])){
$_SESSION['items']=array(array($displays[0],$displays[1],$displays[2],$displays[3],$displays[4],"1"));
}//end if

 

The item is added to the session array with the quantity of 1 being added at the end. I have managed to do a search so that it knows if there is a item already in the array with the same id I just don't know what to do to update that record so that the quantity can be changed i.e. +1

 

Cheers in advance guys :)

 

Rob

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.