our method is depending on the PHP XHTML table class This class for PHP 5 easily creates XHTML valid tables with a simple and easy to remember syntax. Example $table = new table('border="1"'); $table->caption('People'); $table->part('head'); $table->headers('Name',array('Age'=>'title="in years"'),'Country'); $table->part('body','style="color:Blue;"'); $table->row(''); $table->cells('John',23,'USA'); $table->row(''); $table->cell('Jack'); $table->cell('42'); $table->cell('Mexico'); $table->row(''); $table->cell('Philip J. Fry'); $table->cell('23'); $table->cell('India'); $table->part('foot','style="color:Violet;"'); $table->cell("Total :"); $table->cell(23+42+23); # empty cell $table->cell(); # reopen a closed part, and add a row # won't increment the total, it's only an example $table->part('body'); $table->row('style="color:Green;"'); $table->cells('Igor',43,'Russia'); echo($table); PHP: XHTML Output <table border="1"> <caption>People</caption> <thead> <tr><th>Name</th> <th title="in years">Age</th> <th>Country</th> </tr> </thead> <tfoot style="color:Violet;"> <tr><td>Total :</td> <td>88</td> <td> </td> </tr> </tfoot> <tbody style="color:Blue;"> <tr><td>John</td> <td>23</td> <td>USA</td> </tr> <tr><td>Jack</td> <td>42</td> <td>Mexico</td> </tr> <tr><td>Philip J. Fry</td> <td>23</td> <td>India</td> </tr> <tr style="color:Green;"><td>Igor</td> <td>43</td> <td>Russia</td> </tr> </tbody> </table> Code (markup): Download php-xhtml-table20091206.zip [2.91 KB] http://www.jooria.com/downloads/441/php-xhtml-table20091206.zip Code (markup): or class.table.php [7.82 KB] http://www.jooria.com/view/file/441/0 Code (markup):
Wouldn't it be easier to do: $row = array("Jack", "Harkness", "42"); $table->addrow($row) PHP: ? Because then you can do: $result = mysql_query("SELECT * FROM `employees` ORDER BY `employeeid` ASC"); while($row = mysql_fetch_assoc($result)) { $table->addrow($row); } PHP: Just saying.
I do this for some of the scripts that I have. I really like it, since it cleans up main coding, at least I think it does.