Building html tables from query data... faster?
- by Andrew Heath
With my limited experience/knowledge I am using the following structure to generate HTML tables on the fly from MySQL queries:
$c = 0;
$t = count($results);
$table = '<table>';
while ($c < $t) {
$table .= "<tr><td>$results[0]</td><td>$results[1]</td> (etc etc) </tr>";
++$c;
}
$table .= '</table>';
this works, obviously. But for tables with 300+ rows there is a noticeable delay in pageload while the script builds the table. Currently the maximum results list is only about 1,100 rows, and the wait isn't long, but there's clearly a wait.
Are there other methods for outputting an HTML table that are faster than my WHILE loop? (PHP only please...)