Return to Snippet

Revision: 22882
at January 25, 2010 10:57 by ginoplusio


Initial Code
function getHtmlTable($result){
	// receive a record set and print
	// it into an html table
	$out = '<table>';
	for($i = 0; $i < mysql_num_fields($result); $i++){
		$aux = mysql_field_name($result, $i);
		$out .= "<th>".$aux."</th>";
	}
	while ($linea = mysql_fetch_array($result, MYSQL_ASSOC)) {
		$out .= "<tr>";
		foreach ($linea as $valor_col) $out .= '<td>'.$valor_col.'</td>';
		$out .= "</tr>";
	}
	$out .= "</table>";
	return $out;
}

Initial URL
http://www.barattalo.it/2010/01/25/10-php-usefull-functions-for-mysql-stuff/

Initial Description


Initial Title
MYSQL Recordset to HTML table

Initial Tags
mysql, php, html

Initial Language
PHP