Jump to content

loop help


MDanz

Recommended Posts

i've been doing while loops for this problem .. i dont think its the right way though.

 

i have a set of boxes each with a boxid(apart from the first), which is the id(mysql) of the previous box. 

 

e.g.

box 1 has id 1

box 2 has id 2 and boxid 1,

box 3 has id 3 and boxid 2 etc

 

you see the boxid is the same as the previous id.

 

i want 10 boxes to display , when i'm trying to loop this i am using a while loop, but i keep on having to use another while loop inside, just to match the boxid with previous id, to get the next box to display. so i would have to do 10 while loops inside one another, which isn't good practice.

 

is there a better way to do this? for loop? 

 

another example

 

e.g.

box 1 has id 239

box 2 has id 456 and boxid 239,

box 3 has id 123 and boxid 456 etc

 

Link to comment
Share on other sites

[id=239] [id=456,boxid=239][id=123,boxid=456]

 

how would you go about doing this? instead of multiple while loops inside each other.

 

i've been doing mysql_query select boxid='$previousid' and then doing while loop inside while loop per box.  there must be a better way.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.