Revision: 4468
Updated Code
at December 14, 2007 13:18 by cubit
Updated Code
function _mysql_result_all($result, $tableFeatures="border='1'",$nodata=" ") { $tableDebug .= "<!--Debugging output for SQL query-->\n\n"; echo "<table $tableFeatures>\n\n"; $noFields = mysql_num_fields($result); echo "<tr>\n"; for ($i = 0; $i < $noFields; $i++) { $field = mysql_field_name($result, $i); echo "\t<th>$field</th>\n"; } while ($r = mysql_fetch_row($result)) { echo "<tr>\n"; foreach ($r as $column) { echo "\t<td>"; if ($column == NULL) { echo "$nodata"; } else { echo $column; } echo "</td>\n"; } echo "</tr>\n"; } echo "</table>\n\n"; echo "<!--End debug from SQL query-->\n\n"; return $tableDebug; } _mysql_result_all($result);
Revision: 4467
Updated Code
at December 14, 2007 13:17 by cubit
Updated Code
function _mysql_result_all($result, $tableFeatures="border='1'",$nodata=" ") { $tableDebug .= "<!--Debugging output for SQL query-->\n\n"; echo "<table $tableFeatures>\n\n"; $noFields = mysql_num_fields($result); echo "<tr>\n"; for ($i = 0; $i < $noFields; $i++) { $field = mysql_field_name($result, $i); echo "\t<th>$field</th>\n"; } while ($r = mysql_fetch_row($result)) { echo "<tr>\n"; foreach ($r as $column) { echo "\t<td>$column"; if ($column == NULL) { echo "$nodata"; } else { echo $column; } echo "</td>\n"; } echo "</tr>\n"; } echo "</table>\n\n"; echo "<!--End debug from SQL query-->\n\n"; return $tableDebug; } _mysql_result_all($result);
Revision: 4466
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 14, 2007 12:43 by cubit
Initial Code
function _mysql_result_all($result, $tableFeatures="") { $table .= "<!--Debugging output for SQL query-->\n\n"; $table .= "<table $tableFeatures>\n\n"; $noFields = mysql_num_fields($result); $table .= "<tr>\n"; for ($i = 0; $i < $noFields; $i++) { $field = mysql_field_name($result, $i); $table .= "\t<th>$field</th>\n"; } while ($r = mysql_fetch_row($result)) { $table .= "<tr>\n"; foreach ($r as $column) { $table .= "\t<td>$column</td>\n"; } $table .= "</tr>\n"; } $table .= "</table>\n\n"; $table .= "<!--End debug from SQL query-->\n\n"; return $table; } print _mysql_result_all($result);
Initial URL
http://www.thescripts.com/forum/thread276.html
Initial Description
Not mine. Changed from the original it to suit my needs.
Initial Title
MySQL Query to HTML Table
Initial Tags
php, html
Initial Language
PHP