Hi John - I have come up against this one a number of times, and have found
that the following works pretty nicely - although there may be better ways
out there
- get your records from the db
- loop thru them, using some sort of ID field to print each row in your
table with names something like;
"fieldname|" . $ID
- each field obviously can be edited to whatever, then the whole thing is
submitted
now, when submitted (either back to itself or to another script or whatever)
- loop thru $HTTP_POST/GET_VARS
- when you find, say "title|" . $ID, which might actually appear as
$HTTP_POST_VARS["title|4"] then you can process and update that
entire record, i have copy-pasted a snippet of code below, hope that helps
<?php
[snip other code]
else if ($save) {
foreach ($HTTP_POST_VARS as $name=>$value) {
if (substr($name, 0, 12) == "description|") {
$descriptionID = substr($name, 12);
$SQL = "UPDATE fee_descriptions SET title='$value'
WHERE descriptionID='$descriptionID'";
if ($updated = db_query($SQL))
$msg = urlencode("Fee Descriptions
successfully updated.");
else
$msg = urlencode("There was an error
updating the Fee Descriptions, please try again.");
}
}
}
?>
hope some of those ramblings help
beau
// -----Original Message-----
// From: John Hawkins [mailto:[EMAIL PROTECTED]]
// Sent: Thursday, 17 January 2002 4:41 PM
// To: php-db list
// Subject: [PHP-DB] Updating multiple rows from a single form
// submission
//
//
// Hi again!
//
// I have a MySQL table named ratings. It has 5 fields in
// it like this:
// ID, name, deposit, days, hands
//
// The table has 10 rows in it with assorted data in each
// field.
//
// Here is what I would like to to:
//
// 1. Display all 10 rows of data on the page in a table
// with the fields deposit, days and hands in form input
// boxes so the numbers inside can be edited.
// 2. After all the numbers are updated and the user hits
// submit, I would like to have the database updated with
// all the data entered for all rows.
//
// Doing this type of thing for a single record at a time
// is a no brainer. But, when it comes to doing it for
// multiple entries at a single time, I am a bit stumped.
//
// Here are my questions:
// - What do I name the form fields?
// - Upon processing, how do I ensure it writes the
// proper data to the proper record?
//
// Thanks for your help!
//
// John
//
// __________________________________________________
// Do You Yahoo!?
// Send FREE video emails in Yahoo! Mail!
// http://promo.yahoo.com/videomail/
//
// --
// PHP Database Mailing List (http://www.php.net/)
// To unsubscribe, e-mail: [EMAIL PROTECTED]
// For additional commands, e-mail: [EMAIL PROTECTED]
// To contact the list administrators, e-mail:
// [EMAIL PROTECTED]
//
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]