Page 1 of 1

storing text box values in a session

Posted: Tue Mar 09, 2010 4:48 am
by cjconnor24
Ok this is a bit of a tough one to describe - i basically have a shopping cart (session) which works fine.

The structure is as follows:

Code: Select all

 
$_SESSION['cart'][(productid)][(pricingoption)] = $qty;
 
so an example with product 4 and pricing option 3 might look like this:

Code: Select all

 
$_SESSION['cart'][4][3] = 1;
 
As i say, this works great. I now want to add options which would generate dynamic text boxes per product. i.e. for business cards.

In my database i have a field where i can store the initial fields like so

"Name|Job Title|Telephone"

these are then exploded to create the text boxes like so

Code: Select all

 
$options = explode("|",$data->options);
 
foreach($options as $key=>$value){
#... GENERATE THE TEXT BOXES
}
 
Again this works fine.

This is where i'm stuck - how can i get these values and store them in the above cart? Even if i could store them as an array.

I should say that not every product will have options so this has to be dynamic.

If you need any more info please just ask.

:)