1st off -- remove the single quotes;
$shoppingcart = array("buy"=>$buy, "quantity"=>$quantity);
2nd. I would do this:
$shoppingcart[] = array("buy"=>$buy, "quantity"=>$quantity);
This is the same as array_push, but it's a little easier. $shoppingcart[0]
now contains your array. If you did it again, $shoppingcart[1] would
contain the next item.
Peter
On Mon, 2 Jun 2003, Boa Constructor wrote:
> Hey again all, right I've tried using an associative array for my shopping
> cart and I've encountered two problems - so far. The first problem is that
> I can't only add one item to the cart and the second problem is that when
> viewing the cart it shows two items in it. I think this is because there
> are two parts to the array, "buy" and "quantity" and when I'm counting the
> amount of items in the array its counting all the components of the array.
>
> How can I add items to the end of this associative array? Some of the code
> I'm using is below. I'm also thinking that if the below code works then
> there is something wrong with the way I'm reading back the items in the
> cart. Ugh I dunno!
>
> Any ideas?
>
>
>
> Cheers,
>
> Graeme :)
>
>
>
> <?PHP
>
> session_start();
>
> session_name('shoppingcart');
>
> if($buy != "")
>
> {
>
>
>
>
> $shoppingcart = array( 'buy'=>'$buy', 'quantity'=>'$quantity' );
>
>
>
>
> session_register('shoppingcart');
>
>
>
> }
>
>
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
---------------------------------------------------------------------------
Peter Beckman Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---------------------------------------------------------------------------
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php