note 33384 added to function.odbc-result-all

From: Date: Tue, 24 Jun 2003 15:21:52 +0000
Subject: note 33384 added to function.odbc-result-all
Groups: php.notes 
Request: Send a blank email to php-notes+get-50946@lists.php.net to get a copy of this message
I've written this little function that functions simirarly to odbc_result_all, but works with MySQL: /** * This function emulates the odbc_result_all function, which will return a HTML table cosisting of * the results of an SQL query. * Usage: pass a mysql result set to this function, and it will return (not output) a string containing * an HTML table * Parameters: * - $result is your mysql result set (result of a mysql_query() function call) * - $tableFeatures is a string containing any HTML TABLE features you would like in the table * (eg. BORDER="0" etc.) */ 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 $kolonne) { $table .= "\t<td>$kolonne</td>\n"; } $table .= "</tr>\n"; } $table .= "</table>\n\n"; $table .= "<!--End debug from SQL query-->\n\n"; return $table; } Enjoy... ---- Manual Page -- http://www.php.net/manual/en/function.odbc-result-all.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33384 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33384&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33384&report=yes

« previous php.notes (#50946) next »