storing text box values in a session

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cjconnor24
Forum Newbie
Posts: 13
Joined: Wed Oct 29, 2008 6:31 am

storing text box values in a session

Post 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.

:)
Post Reply