Jump to content

Dynamic Table?


adilmarwat

Recommended Posts

make 2 css for blue & white respectively.in the for or while loop whatever u use, find the row serial no is odd or even.make a if clause in the class section in the td like

<td class = "<?php if (serial no is odd, echo blue class... else echo white clsss.);?>"> your content</td>
I think you can implement the concept with the Codes. It's very easy dude..
Link to comment
Share on other sites

Most of the time people use a counter and the mod operator to do that. If you only have 2 possible options, you can also just use a boolean flag:

$odd = true;for ($i = 0; $i < 5; $i++){  if ($odd)	echo '<div class="class1">';  else	echo '<div class="class2">';  echo 'xxx</div>';  $odd = !$odd;}

Each time through that loop $odd will be toggled, so it will alternate between printing divs which have class1 or class2.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...