Page 1 of 1

insert html between mysql records

Posted: Thu Apr 15, 2010 10:33 am
by pertrai1
Hi, I am wondering if it is possible to add code after x amount of records in my while loop from mysql. I want to be able to insert a div that clears floats after 3 records. So for example:

Code: Select all

<?php $query_classifieds = mysql_query("SELECT id, categoryName, permalink, is_active FROM classified_categories WHERE is_active = '1' && parentId = '$parentId' ORDER BY categoryName ASC");
              while ($row_classcat = mysql_fetch_array($query_classifieds)) { ?>
                <div class="classified-categoryBox">
                	<h2 class="subcategory"><a href="./<?php echo $row_parent['permalink']; ?>/<?php echo $row_classcat['permalink']; ?>.html" title="<?php echo $row_classcat['categoryName']; ?> classified ads"><?php echo $row_classcat['categoryName']; ?></a></h2>
                	<?php 
                	$id = $row_classcat['id'];
                	$catcount = mysql_query("SELECT id FROM classifieds WHERE categoryid = '$id'");
                	$totalads = mysql_num_rows($catcount);
                	?>
                	<p>Current number of ads: <?php echo $totalads; ?></p>
                </div><!--end classified ad box-->
   <?php } ?>
So each of my div's are floating to the left. Each record is stored in a div. I would like to insert a div that clears the floats for a new line of div's. I hope this makes sense. COuld someone show me how this could be done, if it can be done. Thank you

Rob

Re: insert html between mysql records

Posted: Thu Apr 15, 2010 10:50 am
by Weiry
Posting Code in the Forums
Read It.
pertrai1 wrote:after 3 records

Code: Select all

$i=0;
while(){
    if($i%3){ print "new div"; } // ($i % 3) every 3 records.
    $i++;
}

Re: insert html between mysql records

Posted: Thu Apr 15, 2010 11:11 am
by pertrai1
Sorry I did not read the posting guidelines first. I won't do this again.