PHPBuilder - columns 2 variables.



RSS Twitter
Snippets Databases

columns 2 variables.

by: Owen Borstad
|
June 22, 2001

Version: 1.0

Type: Function

Category: Databases

License: GNU General Public License

Description: Sets a series of variables named from the column names to their values from a row.



function Columns2Vars ($db, $database, $row, $debug = 0) {
// Usage: Columns2Vars (SQL connection, database Name, current fetched row of database to set vars values to, 1 if you want to see the result);
  $describe = mysql_query("DESCRIBE $database", $db); 
  $numFields = mysql_num_rows($describe); 
  while ($fields = mysql_fetch_array($describe) ) {
    $temp = $fields["Field"];
    global $$temp; ${$temp} = $row[$temp];
    if ($debug) printf("var '%s'=value:'%s'<br />",$temp, ${$temp});
  }
}

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Owen Borstad

Comment:



Comment:

(Maximum characters: 1200). You have characters left.