Jump to content

Dynamic Table?


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.. Edited by bluebel
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...