mjurmann Posted July 9, 2007 Share Posted July 9, 2007 Hello. I am trying to list each client in my database. The loop begins with the Clients table and starts spitting out information about the client. Then the second loop begins. This loop goes through the Projects table and it is suppossed to count the number of projects that belong to each member. Instead of looping through the Projects table each time the Client's loop loops through and gets information for the next client, the Projects table is only looped through on the first run-through of the first client. Can someone tell me how I can get the loop to start at the beginning of the Projects table each time the Clients loop starts over? Thanks so much in advance...teach me a thing or two, I need it. <?php do { ?> <tr> <td><a href="admin-client-detail.php?id=<?php echo $row_Clients['memberID']; ?>"><?php echo $row_Clients['memberID']; ?></a></td> <td><?php echo $row_Clients['lastName']; ?>, <?php echo $row_Clients['firstName']; ?></td> <td> <?php $projects = 0;?> <?php do { ?> <?php if ($row_Projects['clientID'] == $row_Clients['memberID']) { ?> <?php echo "YES";?><?php $projects++;?> <?php } else { echo "NO"; echo $row_Projects['clientID']; }?> <?php echo $row_Projects['projectID'];?> <?php } while ($row_Projects = mysql_fetch_assoc($Projects)); ?> <?php echo $projects;?> </td> <td><?php if ($row_Projects['projectComplete'] == 'y') { ?> <img src="images/buttons/complete.jpg" /> <?php } else { ?> <img src="images/buttons/notcomplete.jpg" /> <?php }?> </td> </tr> <?php } while ($row_Clients = mysql_fetch_assoc($Clients)); ?> Quote Link to comment https://forums.phpfreaks.com/topic/59012-a-repeated-region-within-a-repeated-region/ Share on other sites More sharing options...
BillyBoB Posted July 9, 2007 Share Posted July 9, 2007 could u just do: <?php while ($row_Clients = mysql_fetch_assoc($Clients)) { ?> <tr> <td><a href="admin-client-detail.php?id=<?php echo $row_Clients['memberID']; ?>"><?php echo $row_Clients['memberID']; ?></a></td> <td><?php echo $row_Clients['lastName']; ?>, <?php echo $row_Clients['firstName']; ?></td> <td> <?php $projects = 0;?> <?php while ($row_Projects = mysql_fetch_assoc($Projects)) { ?> <?php if ($row_Projects['clientID'] == $row_Clients['memberID']) { ?> <?php echo "YES";?><?php $projects++;?> <?php } else { echo "NO"; echo $row_Projects['clientID']; }?> <?php echo $row_Projects['projectID'];?> <?php } ?> <?php echo $projects;?> </td> <td><?php if ($row_Projects['projectComplete'] == 'y') { ?> <img src="images/buttons/complete.jpg" /> <?php } else { ?> <img src="images/buttons/notcomplete.jpg" /> <?php }?> </td> </tr> <?php } ?> i would recode it all but i just tried to fix what i could just try it if it doesnt work then i will code it for you Quote Link to comment https://forums.phpfreaks.com/topic/59012-a-repeated-region-within-a-repeated-region/#findComment-292946 Share on other sites More sharing options...
sasa Posted July 9, 2007 Share Posted July 9, 2007 use mysql_data_seek() function to reset $Projects to first row (index = 0) Quote Link to comment https://forums.phpfreaks.com/topic/59012-a-repeated-region-within-a-repeated-region/#findComment-292971 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.