RE: [PHP-DB] Is there a short way to?
| From: | USA) | Date: | Tue, 15 Apr 2003 13:46:47 +0000 |
| Subject: | RE: [PHP-DB] Is there a short way to? | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-27094@lists.php.net to get a copy of this message | ||
You can do an insert for your first "relevant bit" and use updates for each consecutive
bit. If you use the function mysql_insert_id to set a hidden field in pages 2-n of your forms to the
key field that you just inserted and you don't have any not null constraints on the following
fields.
Example:
page1.php:
<form action="page2.php">
<input name='myFirstField'>
</form>
page2.php:
<?PHP
$q = "insert into table (myFirstField) values ('$myFirstField')";
mysql_query($q,$con);
$insertedID = mysql_insert_id($con); ?>
<form action="page3.php">
<input name='mySecondField'>
<input type='hidden' name='insertedID' value='<?PHP echo $insertedID;
?>'>
</form>
page3.php:
<?PHP
$q = "update table set mySecondField='$mySecondField' where IDtable =
$insertedID";
mysql_query($q,$con); ?>
<form action="page4.php">
<input name='myThirdField'>
<input type='hidden' name='insertedID' value='<?PHP echo $insertedID;
?>'>
</form>
and so on and so on...
<>< Ryan
-----Original Message-----
From: Dave Carrera [mailto:dave@ephgroup.com]
Sent: Tuesday, April 15, 2003 7:30 AM
To: php-db@lists.php.net
Subject: [PHP-DB] Is there a short way to?
Hi All
I have a MySql table that I am trying to post data from a form (basic
stuff but wait a minute)
It has thirty cols but what I am trying to do is not have a form with 30
fields but split it into little relevant bits and post them bits as I
go.
My question is do I HAVE to "insert into table
(name,all,the,30,cols,here) values(var1,var2,var3,and,so,on)
Or is there a glamorous way of only putting the data from the form into
the affected rows?
And help, examples or online resources very much appreciated.
Thank You
Dave C
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.471 / Virus Database: 269 - Release Date: 10/04/2003
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php