• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

Mysql update from form input

biggulp

Active Member
I want to do two things. The first one I know how to do - display an entire mysql table on a page with every cell being a form input instead of a regular table cell. Then I have a whole page of text fields populated with the data from the mysql table.

The hard part is as follows: I want to have a little button at the bottom of this table that will update the entire mysql table in the database with any changes that were made to the data in the text boxes.

Can I do that, or can I only update one record at a time? Do I have to use some kind of special array to hold all the variables and POST them in some special way? I've tried, and I have code that does the first part but chokes on the updating. Any suggestions?
 
Can't you just do one UPDATE after another? Or something like:
Code:
UPDATE table SET blah='$blah',blah2='$blah2'
and so one, just keep going...

Or, if you use mysql_fetch_row, you could do something like this:
PHP:
while($data = mysql_fetch_row($query));
{
  mysql_query("UPDATE table SET item1='$data[1]', item2='$data[2]', item3='$data[3]'");
}
 
Last edited:
Back
Top