A user will select a tournament to register for, then add a team, then I store the following into a session:

$teamID;
$tournyID;
$gatefee;
$cost;

When they click add to cart I update the session using this:

$_SESSION[] = $teamID;
$_SESSION[] = $tournyID;
$_SESSION[] = $gatefee;
$_SESSION[] = $cost;

My array comes out like this:

Array
(
[cart] => Array
(
[] => Array
(
[team] => 2137
[tournament] => 24490
[gatefee] =>
[cost] => 575
)

)

)

As you can see there is no KEY so when someone adds another tournament to their cart it overwrites this one. How can I get the KEY to number 0, 1, 2, etc... with each addition to the cart?

Thanks in advance!!!!

$_SESSION['cart'][] = array('team'=> $teamID,'tournament'=>$tournyID,'gatefee'=>$gatefee,'cost' => $cost);

Note the code tags!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.