1
demian
help with odd, even table styling
  • 2010/1/23 3:42

  • demian

  • Quite a regular

  • Posts: 225

  • Since: 2008/4/29


Ok im currently developing a custom module for my site..how do i style this table with odd even XOOPS style like in the profile...

something like

odd row- class=odd
even row - class=even

le="color: #000000"><?php echo "<table><tr>"; echo "<td>Bil</td>"; echo "<td>Name</td>"; echo "<td>Title</td>"; echo "<td>Unit</td>"; echo "</tr>"; while($row = mysql_fetch_array($result)) { $id=$row['id']; echo "<tr>"; echo "<td>"; echo $bil++; echo "</td>"; echo "<td><b>" . $row['name'] . "</b></td>"; echo "<td>" . $row['title'] . " " . $row['gred'] . "" . $row['No'] . "</td>"; echo "<td>" . $row['unit'] . "</td>"; echo "</tr>"; } echo "</table>";echo "";

2
ghia
Re: help with odd, even table styling
  • 2010/1/23 5:10

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


le="color: #000000"><?php $class = ($i % 2 == 0) ? 'even' : 'odd'; echo "<tbody><tr class='{$class}'>

$i is a counter inside the loop.

Better is to use a template. An example with odd, even is in eg the templates for the blocks of the system module.

3
demian
Re: help with odd, even table styling
  • 2010/1/23 12:22

  • demian

  • Quite a regular

  • Posts: 225

  • Since: 2008/4/29


thats the plan using template...this is a temp solution

thanks ghia...it almost work but it only use the even class for all row


i got another solution from another forum i use this

le="color: #000000"><?php $int = 0; while (/* ... */) { echo '<tr class="', ++$int & 1 ? 'even' : 'odd', '">'; // ... }


and it works

4
ghia
Re: help with odd, even table styling
  • 2010/1/23 13:29

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


(Is odd and even not reversed on that one?)

5
demian
Re: help with odd, even table styling
  • 2010/1/23 15:07

  • demian

  • Quite a regular

  • Posts: 225

  • Since: 2008/4/29


..reversed ? no


it works exactly how i wanted..

actually i got the answer from a php forum

Login

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits