468,249 Members | 1,512 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,249 developers. It's quick & easy.

Code trouble, looping, doesn't read while loop

Hi there,

below a little code snippet that causes me some headaches.
I had a similar one working fine, until I needed to redo my code on this one
page entirely.
Now my problem is, that the test in the first line is performed and the
variable $top_in_ord is set. Problem is only, that the following while loop
for some reason doesn't give me any output as it was expected.
As the initial check turns out positive, so the $topping is in $order, I
should actually have $field set during the while loop, yet I get just
nothing.
This does have serious implications on my code that follows, as that code
depends on $field being set, which it should.

Anyone able to locate some mishap here?

Expand|Select|Wrap|Line Numbers
  1. // check if topping is part of the ordered product,
  2. // if so, determine the fieldname, $field
  3. if(substr($order,strpos($order,$topping),strlen($topping))==$topping) {
  4. $top_in_ord = "TRUE";
  5. // as $top_in_ord is set to true, one of $top1-$top9 contains $topping
  6. while (list($top1, $top2, $top3, $top4, $top5, $top6, $top7, $top8, $top9) =
  7. mysql_fetch_array($result)){
  8. $i=1;
  9. do {
  10. if(${"top".$i} == $topping) $field = "top".$i;
  11. $i++;
  12. } while ($i<10);
  13. }
  14. }
  15.  
My code hasn't been refined for now, for now only workability counts,
refining and optimizing is second.

I would highly appreciate any ideas.

/Andreas

--
Registeret Linux user #292411
Jul 16 '05 #1
1 1921
Andreas Paasch wrote:

Figured it out, somehow my sql request got lost in my code .... I better
investigate that one properly.
--
Registeret Linux user #292411
Jul 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

699 posts views Thread by mike420 | last post: by
38 posts views Thread by jrlen balane | last post: by
10 posts views Thread by Nick L | last post: by
19 posts views Thread by Dave | last post: by
3 posts views Thread by Jamie Risk | last post: by
9 posts views Thread by TF | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.