Re: array type problem
From: AJ (nospam_at_redcatmedia.net)
Date: 06/07/04
- Next message: Manuel Lemos: "Re: Please help: Prevent Multiple Instances"
- Previous message: Jerry: "Please help: Prevent Multiple Instances"
- In reply to: dogeater: "Re: array type problem"
- Next in thread: Tony Marston: "Re: array type problem"
- Reply: Tony Marston: "Re: array type problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 7 Jun 2004 08:17:15 +0000 (UTC)
"dogeater" <ggombo69@yahoo.com> wrote in message
news:7fcc8a1.0406061601.33ac913f@posting.google.com...
> andy@redcatmedia.net (AJ) wrote in message
news:<51cfbdd0.0406060332.14ff6567@posting.google.com>...
> > andy@redcatmedia.net (AJ) wrote in message
news:<51cfbdd0.0406051311.68d520a6@posting.google.com>...
> >
> > > This is the bit of code that I'm running:
> > >
> > > <?php do {
> > > $cart_total=$cart_total+$row_current_cart['product_price'];
> > > } while ($row_current_cart = mysql_fetch_assoc($current_cart));
> > > ?>
> >
> > And to actually make some sense of that now that my Mac is playing
> > again...
> >
> > Basically, what's happening is that the second time I try to print the
> > cart out, or parts of it, on one page, it's got to the end of the
> > array and prints nothing.
> >
> > I've tried reset($current_cart) but no joy.
> >
> > Any ideas please.
> >
> > Andy
>
> You might've typed in your snippet of code wrong here but I believe
> the while condition needs to have == not =.
Not sure about that. This works in as much as it displays the cart. The
problem I have is when I run this bit of code twice. I'm pretty sure that
the problem is because it loops through the array and displays the contents
of each element. Once it's finished at position 'n', the array counter
stays at position 'n'. What I need to do is run the code again from
position 0. I've even tried mysql_data_seek(0). This almost works but you
get:
[blank]
Product 1 £9.99
Total £19.98
when you run it the second time, even though there is only one item in the
cart. The first time it runs, it displays what it should.
Andy
- Next message: Manuel Lemos: "Re: Please help: Prevent Multiple Instances"
- Previous message: Jerry: "Please help: Prevent Multiple Instances"
- In reply to: dogeater: "Re: array type problem"
- Next in thread: Tony Marston: "Re: array type problem"
- Reply: Tony Marston: "Re: array type problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|