| | |
Update multiple rows from loop?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Alright, this one has me stuck. I know it's possible, because I've seen an example in another thread, but mine is slightly different, and I can't figure it out.
Ok, I have one script that pulls all the rows from a database, and displays the data using a while loop. It displays that data in forms, so the user can change it, and hit a submit button.
I need that form to be able to update any rows that the user changes on it. (or all of them even if they haven't changed, that's probably easier.)
How do I pull the entries from each of the rows to update all those rows with the new data?
Here is a thread that is accomplishing what I'm trying to do, but it's so long and complicated, I can't make sense of it: http://www.daniweb.com/forums/showth...+in+while+loop
Ok, I have one script that pulls all the rows from a database, and displays the data using a while loop. It displays that data in forms, so the user can change it, and hit a submit button.
I need that form to be able to update any rows that the user changes on it. (or all of them even if they haven't changed, that's probably easier.)
How do I pull the entries from each of the rows to update all those rows with the new data?
Here is a thread that is accomplishing what I'm trying to do, but it's so long and complicated, I can't make sense of it: http://www.daniweb.com/forums/showth...+in+while+loop
Sorry, try this one.
And like I said, the one in that post is way more than I'm trying to do, but it addresses the same problem I'm having. In the simplest form, I've got something like this:
So I basically need to know how to pass the array of variables that this table produces from the form input field named "total$id" on to the form script, so that it can process all those values.
And like I said, the one in that post is way more than I'm trying to do, but it addresses the same problem I'm having. In the simplest form, I've got something like this:
php Syntax (Toggle Plain Text)
<? echo "<table> <tr> <th>Column1</th> <th>Column2</th> <th>Column3</th> </tr> <form method='post' action='myform.php'>"; $query = "SELECT * FROM mytable"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { $id=$row['id']; $mynum=$row['mynum']; echo "<tr> <td>Value 1</td> <td>Value 2</td> <td><input type='text' name=total$id value='$mynum'></td> </tr>"; } echo "<tr><td><input type='submit' name='submit' value='Submit'></form></td></tr></table>"; ?>
So I basically need to know how to pass the array of variables that this table produces from the form input field named "total$id" on to the form script, so that it can process all those values.
Last edited by nathanpacker; Nov 4th, 2007 at 9:34 pm.
![]() |
Similar Threads
- updating multiple rows with one form (PHP)
- insert multiple rows in database (MS SQL)
- Store multiple selection from pagination info into single array (PHP)
- How to store multiple selection? (VB.NET)
- Update Multiple Records (ASP)
- multiple row update (C#)
- how do i update to Access db? (C#)
Other Threads in the PHP Forum
- Previous Thread: Dynamically updating values in a form as you type?
- Next Thread: Problem Setting up PHP/SQL Server dev enviroment
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array basics beginner binary broken cakephp checkbox class cms code codingproblem combobox cron curl database date directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla js limit link login loop mail menu mlm mobile mod_rewrite multiple mysql oop paging parse paypal pdf php problem procedure query radio random recursion regex remote script search server sessions smash sms soap source space sql structure syntax system table tutorial up-to-date update upload url validation validator variable video web webapplications xml youtube





