#native_company# #native_desc#
#native_cta#

columns 2 variables.

By Owen Borstad
on 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});
  }
}