Try this:
I use it so that I can add variable names to a db table, then access them
throughout the script.

## Get the report_conf variables
   $sql = "SELECT *
           FROM report_conf";
    $prefs = get_rowset($conn_id,$sql);
      foreach($prefs as $pref){
        $foo = $pref['name'];
        $$foo = $pref['name_value'];

The array you'd be interested in is $prefs, and it looks like this:
$key[0] = 'var1';
$value[0] = 'blue';
$key[1] = 'var2';
$value[1] = 'green';

After running the above, then
$var1 = 'blue';
$var2 = 'green';

I'm sure you'll need to tweak it a little, but the secret its the $$foo
(with two $ signs)
If $foo = 'aname'
then $$foo = $aname

The get_rowset is a function I've written to symplify my code, it returns
rows in an array from the DB

Gary Every
Sr. UNIX Administrator
Ingram Entertainment
(615) 287-4876
"Pay It Forward"

-----Original Message-----
From: Michael Conway [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 07, 2003 4:47 PM
Subject: [PHP-DB] Getting array values into a query

I've been attempting to take the values from an array pulled from a
session to supply the variable in a WHERE clause. list() provides only
the first value as expected. implode() the last.  Any suggestions or
should I just load the values I want in the session through a query on
the previous script and call it directly to the function I want to use?


Michael Conway


(703) 968-8875


Reply via email to