Re: global vars
| From: | olinux | Date: | Wed, 28 Mar 2001 22:20:51 +0000 |
| Subject: | Re: global vars | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-7944@lists.php.net to get a copy of this message | ||
nevermind, sorry
it was a stupid comma in my sql query...
what i have is very sool tho, so if you would like the script its great!
i derived it, almost entirely from Dan LaFlamme's NOT working script at
http://phpbuilder.com/columns/laflamme20001016.php3
olinux
----- Original Message -----
From: "olinux" <olnx@yahoo.com>
To: "PHP-DB" <php-db@lists.php.net>; <PHPLearners@yahoogroups.com>
Sent: Wednesday, March 28, 2001 2:06 PM
Subject: [PHP-DB] global vars
I am working with global variables and functions, specifically calling a
function inside another function.
I checked the online docs and don't see any problems with what i have... i
declare the table_name as global inall functions
What I am trying to do is DELETE all entries for a uid before INSERTING the
new skills
my insert_skills() calls the function to DELETE entries and then the
function that creates the INSERT query
the lookup_skills table columns looks like this.
| id | uid | skills_id |
here are a couple excerpts from my code:
table_name = "lookup_skills";
...
function insert_skills($uid, $skills) {
global $table_name;
purge_lookup($table_name, "1");
$query = create_checkbox_query($skills, $table_name, "1");
...
function purge_lookup($table, $uid) {
global $table_name;
$q = "DELETE FROM $table, WHERE uid = $uid";
mysql_query($q);
}
...
function create_checkbox_query($arr, $table, $uid) {
global $table_name;
$q = "INSERT INTO $table (uid, skill_id) VALUES";
foreach ($arr as $check) {
$q .= " ( $uid , $check )" . ",";
}
return substr($q, 0, -1);
}
insert_skills("1", $skills);
thanks much,
olinux
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com