MySQL Query to HTML Table

function _mysql_result_all($result, $tableFeatures="border='1'",$nodata=" ") {
$tableDebug .= "<!--Debugging output for SQL query-->

";
echo "<table $tableFeatures>

";
$noFields = mysql_num_fields($result);
echo "<tr>
";
for ($i = 0; $i < $noFields; $i++) {
$field = mysql_field_name($result, $i);
echo "	<th>$field</th>
";
}
while ($r = mysql_fetch_row($result)) {
echo "<tr>
";
foreach ($r as $column) {
echo "	<td>";
if ($column == NULL) {
echo "$nodata";
} else {
echo $column;
}
echo "</td>
";
}
echo "</tr>
";
}
echo "</table>

";
echo "<!--End debug from SQL query-->

";
return $tableDebug;
}

_mysql_result_all($result);

source

Leave a Reply