943,708 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 5807
  • PHP RSS
Nov 4th, 2007
0

Update multiple rows from loop?

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Posting Whiz in Training
nathanpacker is offline Offline
234 posts
since May 2005
Nov 4th, 2007
0

Re: Update multiple rows from loop?

Sorry,but the link does not exist..
Reputation Points: 28
Solved Threads: 71
Posting Pro
ryan_vietnow is offline Offline
578 posts
since Aug 2007
Nov 4th, 2007
0

Re: Update multiple rows from 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:

php Syntax (Toggle Plain Text)
  1. <?
  2. echo "<table>
  3. <tr>
  4. <th>Column1</th>
  5. <th>Column2</th>
  6. <th>Column3</th>
  7. </tr>
  8. <form method='post' action='myform.php'>";
  9. $query = "SELECT * FROM mytable";
  10. $result = mysql_query($query) or die(mysql_error());
  11. while($row = mysql_fetch_array($result))
  12. {
  13. $id=$row['id'];
  14. $mynum=$row['mynum'];
  15. echo "<tr>
  16. <td>Value 1</td>
  17. <td>Value 2</td>
  18. <td><input type='text' name=total$id value='$mynum'></td>
  19. </tr>";
  20. }
  21. echo "<tr><td><input type='submit' name='submit' value='Submit'></form></td></tr></table>";
  22. ?>

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.
Reputation Points: 10
Solved Threads: 0
Posting Whiz in Training
nathanpacker is offline Offline
234 posts
since May 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Dynamically updating values in a form as you type?
Next Thread in PHP Forum Timeline: Problem Setting up PHP/SQL Server dev enviroment





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC