close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Nested loop won't work

Thread began 8/10/2009 5:48 pm by sandy259886 | Last modified 8/17/2009 5:46 pm by Jason Byrnes | 1451 views | 8 replies |

sandy259886

Nested loop won't work

Why won't this work? I want a list to loop within a looped list from another db table... Looks logical for me, but dataassist won't handle it. Any clues?

<?php do { ?> <p><?php echo $row_rsMin['Title']; ?></p>

<?php do { ?>
<p><?php echo $row_rsSubmin['Title']; ?></p>
<?php } while ($row_rsMin = mysql_fetch_assoc($rsMin)); ?>

<?php } while ($row_rsMin = mysql_fetch_assoc($rsMin)); ?>

Sign in to reply to this post

Jason ByrnesWebAssist

not quite sure what your trying to accomplish with this, but both loops are using the same recordset try changing it to:
<?php do { ?> <p><?php echo $row_rsMin['Title']; ?></p>

<?php do { ?>
<p><?php echo $row_rsSubmin['Title']; ?></p>
<?php } while ($row_rsSubmin = mysql_fetch_assoc($rsSubmin)); ?>

<?php } while ($row_rsMin = mysql_fetch_assoc($rsMin)); ?>

Sign in to reply to this post

sandy259886

did that - won't work

Here is my file. I just don't know if I'm missing braces or parentheses or what??

Attached Files
opp_list.zip
Sign in to reply to this post

Jason ByrnesWebAssist

Can you give a brief description of how the code is behaving versus what you are expecting so I can get a better understanding of what is wrong.

Sign in to reply to this post

sandy259886

detail of results

Well... The outside loop works, but the inside loop only works the first time that the outside loop executes. Then ... the outside loop continues to give correct results without the corresponding results from the inside loop.

Example:

outside result 1
inside result 1
inside result 2
inside result 3
Outside result 2
inside results are missing
Outside result 3
inside results are missing
Outside result 4
inside results are missing

Sign in to reply to this post

sandy259886

still wondering ...

Did you see my reply?

Sign in to reply to this post

Jason ByrnesWebAssist

That is how I would expect the loop to act given the way it is coded.


If you are trying to show inside result records that are related to the currant outside result, you will need to add the recordset for inside results inside the outside results loop, before the inside results loop. For example:

php:
<?php do { ?> <p><?php echo $row_rsMin['Title']; ?></p>


[-- Create rsSubmin Here --]

<?php do { ?>
<p><?php echo $row_rsSubmin['Title']; ?></p>
<?php } while ($row_rsSubmin mysql_fetch_assoc($rsSubmin)); ?>

<?php } while ($row_rsMin mysql_fetch_assoc($rsMin)); ?>
Sign in to reply to this post

sandy259886

I'll give it a go

I will try that. Thank you!

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...