Jump to content

% that thingy


forumnz

Recommended Posts

<?php

$color1 = "#FFFFFF";
$color2 = "#000000";

$i=0;

while($i<10) {

if($i % 2 == 0) {
$bgColor = $color1;
} else {
$bgColor = $color2;
}

$i++;

}
?>

 

Obivously replace your while() loop etc, it was just to show how it works.  Aslong as you have something in your loop so you can keep track of the total number of loops, otherwise it won't alternate.

Link to comment
https://forums.phpfreaks.com/topic/87836-that-thingy/#findComment-449314
Share on other sites

Thanks,

 

I have this loop:

 

while($row = mysql_fetch_array($result))
  {
  $business_name = $row['business_name'];
  echo "<div id=listingmain>" . $business_name . "</div>";
  }

 

How would I incorporate the 'swapping' into it?

 

I think I would have to do something in the first div? Like:

 

echo "<div id=listingmain style=background-color:#" . $arr . ";>" . $business_name . "</div>";

 

Is that along the right lines?

 

Thanks,

Sam.

Link to comment
https://forums.phpfreaks.com/topic/87836-that-thingy/#findComment-449326
Share on other sites

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.