LostNights Posted May 5, 2006 Share Posted May 5, 2006 I want to echo out a page <span class="breaker"></span> after every 12 database results. <?php do { ?> <div class="employee"> <p> <img src="images/<?php echo $row_Recordset1['firstname']; ?>_<?php echo $row_Recordset1['lastname']; ?>.jpg" width="140" height="140" /><br /> <?php echo $row_Recordset1['firstname']; ?><br /> <?php echo $row_Recordset1['lastname']; ?><br /> <?php echo $row_Recordset1['office']; ?><br /> <?php echo $row_Recordset1['phone']; ?> </p> </div> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> Quote Link to comment Share on other sites More sharing options...
ober Posted May 5, 2006 Share Posted May 5, 2006 All you have to do is add a counter variable to the loop. I'm going to modify your code, because do-while loops aren't the normal or preferred way of looping through a recordset... because it will ALWAYS do one before checking the condition and I'm not sure how you're getting your first record that way either... and for that matter, you're jumping in and out of PHP tags FAR too often:[code]<?php if($Recordset1 && mysql_num_rows($Recordset1) > 0){$counter = 0;while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); { if(++$counter == 12) { echo '<span class="breaker"></span>'; $counter = 0; } extract($row_Recordset1);?><div class="employee"><p><img src="images/<?=$firstname?>_<?=$lastname?>.jpg" width="140" height="140" /><br /><?phpecho "$firstname<br /> $lastname<br /> $office<br /> $phone</p>"; ?></div><?php }} ?>[/code] Quote Link to comment 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.