Formatting Tables with CSS |
[eluser]maniac[/eluser]
I am generating tables with php from the database and want to know whether it is possible to change the color of each alternative row. Everything I have tried doesn't work. Thanks for any help.
[eluser]pickupman[/eluser]
Check out the HTML Table Class docs from the user guide. You can see that you can set an alternate row start configuration. Code: //table template
[eluser]John_Betong[/eluser]
[quote author="maniac" date="1271399025"]I am generating tables with php from the database and want to know whether it is possible to change the color of each alternative row. Everything I have tried doesn't work. Thanks for any help.[/quote] Does "Everything" include using alternator()?
[eluser]maniac[/eluser]
I must admit I'm totally new at all this. This is how I was taught to do the tables - <table width="57%" border="1" cellspacing="0" cellpadding="0" align="center"> <tr> <th>Employee ID</th> <th>Employee First Name</th> <th>Employee Last Name</th> <th>Department</th> </tr> <?php foreach($result as $row): ?> <tr> <td><?=$row->empid?></td> <td ><?=$row->empfirstname?></td> <td ><?=$row->emplastname?></td> <td ><?=$row->deptid?></td> </tr> <?php endforeach; ?> </table>
[eluser]pickupman[/eluser]
There is nothing wrong with that. No need to use the table library if don't want to. Just change it up a bit with Code: <?php $this->load->helper('string');?> Or if you are using jQuery you can cheat, and keep your existing markup. Code: //In script block
[eluser]maniac[/eluser]
Thanks for the help, but it didn't work. I added the helper to the controller, would that make a difference? Should it be in the view file? Thanks
[eluser]John_Betong[/eluser]
Try this: Code: // old edit: added missing #
[eluser]John_Betong[/eluser]
[quote author="maniac" date="1271414616"]Worked perfectly. Thank you.[/quote] Looks like my guess was right and there was a missing CSS -> .alt statement.
|
Welcome Guest, Not a member yet? Register Sign In |