RE: Is there a short way to?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:  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


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



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux