function make_table($sql) { $res = mysql_query("$sql"); if (!$res) { die("Query to show fields from table failed"); } $rows_num = mysql_num_rows($res); if (!$rows_num) { echo "

No information avaliable!

"; } else { $fields_num = mysql_num_fields($res); echo ""; // printing table headers for ($i = 0; $i < $fields_num; $i++) { $field = mysql_fetch_field($res); echo "\n"; // printing table rows while ($row = mysql_fetch_row($res)) { echo ""; // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach ($row as $cell) echo ""; echo "\n"; } echo "
{$field->name}"; } echo "
$cell
"; } }