Hello people!!
I'm in the middle of a site planning stage, and while going through the same old scenario where I need some database information to be displayed in tables, I suddenly had an idea which could ease things a lot, and probably increase site performance. Please read and give me your thoughts.
WHAT IF?...
Instead of:
...run a query, bring all the fields, and then make a loop to insert <tr>'s and <td>'s in order to create the table.
Make this:
Create a query that automatically brings every row already formated, so I can just send it to the output. I explain...
SELECT CONCAT('<td>',name,'</td><td>',lastName,'</td>') as tablerow from my_table where condition=true
and then ouptut like this:
PHP Code:
while ($row = mysql_fetch_array($rs)) {
echo "<tr>\n".$row["tablerow"]."\n</tr>\n";
}
Hope you can help me to see any complications I could find using this approach.
NOTE: One I have seen is that the query could become a problem when changing layout, but I think I can easily modify my DB class to construct queries with or without format.
Bookmarks