RE: [PHP-DB] Getting array values into a query

2003-02-10 Thread Gary . Every
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
mailto:[EMAIL PROTECTED]
http://accessingram.com


-Original Message-
From: Michael Conway [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 07, 2003 4:47 PM
To: [EMAIL PROTECTED]
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

[EMAIL PROTECTED]

(703) 968-8875

 




Re: [PHP-DB] Getting array values into a query

2003-02-07 Thread Jason Wong
On Saturday 08 February 2003 06:47, Michael Conway wrote:
 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?

Please post your code.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
A city is a large community where people are lonesome together
-- Herbert Prochnow
*/


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php