Formatting Tables with CSS - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Formatting Tables with CSS (/showthread.php?tid=29631) Pages:
1
2
|
Formatting Tables with CSS - El Forum - 04-15-2010 [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. Formatting Tables with CSS - El Forum - 04-15-2010 [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 Formatting Tables with CSS - El Forum - 04-15-2010 [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()? Formatting Tables with CSS - El Forum - 04-15-2010 [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> Formatting Tables with CSS - El Forum - 04-15-2010 [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 Formatting Tables with CSS - El Forum - 04-15-2010 [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 Formatting Tables with CSS - El Forum - 04-15-2010 [eluser]John_Betong[/eluser] Try this: Code: // old edit: added missing # Formatting Tables with CSS - El Forum - 04-15-2010 [eluser]maniac[/eluser] Worked perfectly. Thank you. Formatting Tables with CSS - El Forum - 04-16-2010 [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. Formatting Tables with CSS - El Forum - 04-16-2010 [eluser]maniac[/eluser] Sorry, what do you mean? |