Jump to content

Recommended Posts

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)); ?>

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

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.