Re: Is this a valid insert
| From: | Stuart McDonald | Date: | Sat, 09 Sep 2000 00:49:43 +0000 |
| Subject: | Re: Is this a valid insert | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-2760@lists.php.net to get a copy of this message | ||
Mike,
Just make two query variables eg:
$query = "INSERT INTO person
VALUES('$firstname','$lastname','$middlename','$birthday',NULL,'$email','$ph
oto')";
$query2 = "INSERT INTO company
VALUES('$name','$city','$state','$zip','$address','$phone','$url')";
That's worked for me in the past...
Here is an example: where I'd update more than one...(it actually looks
through and may insert into sql2 or 4 loads of times..
BTW I made this all up, so it may well be incorrect syntax, but hell - it
works!!!
___start____
if($rid) {//if 2
$sql = "UPDATE food SET
name='$name',address1='$address1',address2='$address2',price='$price',rcom1=
'$rcom1',blurb='$blurb',location='$location',hours='$hours'
WHERE rid=$rid";
for ($i=0;$i<count($cid);$i++) {
$sql2 = "INSERT INTO FoodLookup (rid,cid) VALUES
('$rid','$cid[$i]')";
$result2 = mysql_query($sql2);
}//end of for
for ($a=0;$a<count($eid);$a++) {
$sql4 = "INSERT INTO BarLookup (bid,eid) VALUES
('$rid','$eid[$a]')";
$result4 = mysql_query($sql4);
}//end of for
}//end of if 2
____end____
Stuart
----- Original Message -----
From: Mike Hammonds <mhammonds@knowledgeinenergy.com>
To: <php-db@lists.php.net>
Sent: Saturday, September 09, 2000 3:19 AM
Subject: [PHP-DB] Is this a valid insert
** Reply Requested When Convenient **
I am trying to update two tables at the same time that are in the same
database is this the right way to do this?
$query = "INSERT INTO person
VALUES('$firstname','$lastname','$middlename','$birthday',NULL,'$email','$ph
oto')";
"INSERT INTO company
VALUES('$name','$city','$state','$zip','$address','$phone','$url')";
$result = MYSQL_QUERY($query);
Mike Hammonds, CNE5, MCP-NT
Fellon-McCord & Associates, Inc.
Office: 502.426.4500 Ext. - 7389
Fax: 502.426.8800
mhammonds@knowledgeinenergy.com
----------------------------------------------------------------------------
----
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net