RE: Is there a short way to?

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

 



Dave,

As you go through, you can do separate submits from the same page
(individual forms) that only feed the relevant columns. Or you can have the
user fill out 10 fields, submit that data then move on to another page that
have them fill in another form, submit and so on. Either way, MySQL allows
you to update specific columns in a table using a query like: UPDATE mytable
SET col1='val1',col2='val2',col4='val4',col8='val8',col30='val30'. If you
check the MySQL manual, there should be a pretty good example of the syntax
required. A sigle page with multiple forms and submit buttons might look
like:

<form name="form1" action="submitForms.php" method="post">
<input type="hidden" name="formname" value="form1">
...fields and stuff in here...
<input type="submit">
</form>
.
.
.
<form name="form2" action="submitForms.php" method="post">
<input type="hidden" name="formname" value="form2">
...fields and stuff in here...
<input type="submit">
</form>

Your sumbitForms.php script would check the value of the hidden field
"formname" and use the value of that hidden field to fire the correct UPDATE
query to update a subset of the 30 columns in your database. If you use
multiple pages each with their own form, you can still use the same hidden
field logic to fire the correct query.

Make sense?

None of the code in here is intended to be used as-is; you'll have to modify
and fill in the blanks yourself. There are also probably other ways to
accomplish this.

Hope this helps.
Rich

> -----Original Message-----
> From: Dave Carrera [mailto:dave@ephgroup.com]
> Sent: Tuesday, April 15, 2003 9: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