note 30381 deleted from function.mysql-fetch-row by philip
| From: | philip@php.net | Date: | Mon, 26 Feb 2007 06:56:37 +0000 |
| Subject: | note 30381 deleted from function.mysql-fetch-row by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-123876@lists.php.net to get a copy of this message | ||
Note Submitter: james at unifiedmind dot com
----
function set_variables_after_query($selection) {
// set variables in the caller's environment from a database query
// by James Thornton, http://jamesthornton.com
$row = mysql_fetch_row($selection);
foreach($row as $i => $value) {
$column = mysql_field_name($selection,$i);
$GLOBALS["$column"] = $value;
}
}
// Example:
$selection = mysql_query($sql) or die(mysql_error());
set_variables_after_query($selection);