Jump to content

While Loop with 2 styles...


son.of.the.morning

Recommended Posts

alright guys, i am having a little trouble trying to get atl styles within a while loop and wondered if anyone could help?

 

<?php 
				$rowNum = "0";
				while($record_rows = mysql_fetch_array($records_returned)){
					if(++$rowNum % 2 == 1 ) {


			?>
                <div class="Record-style1">	
                </div>
                <?php } else {?>
                <div class="Record-style2">
                	
                </div>
                <?php }} mysql_close();?>

Link to comment
https://forums.phpfreaks.com/topic/252498-while-loop-with-2-styles/
Share on other sites

$rowNum = "0";
while($record_rows = mysql_fetch_array($records_returned)) {
$style = $rowNum % 2 === 0 ? 'Record-style1' : 'Record-style2';
echo "<div class=\"{$style}\">$data_and_stuff<div>";
$rowNum++;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.