I think the easiest way would be to use each form element as an array, with the key being the ID. Let's pretend you have "id", "username" where "id" is the unique ID. You'd print your forms like:
Then you can loop through the username array, adding to SQL to execute:PHP Code:echo '<form action="action.php" method="post">';
while($row = mysql_fetch_array($result))
{
// Makes (for example) an input element "username[1]", where 1 would be your primary key.
echo '<input type="text" name="username[' . $row['id'] . ']" value="' . $row['username'] . '" />';
}
echo '<input type="submit" /></form>';
Not sure how easy that was to understandPHP Code:foreach($_POST['username'] as $k => $v)
{
mysql_query("UPDATE DB_Stats VALUES('', $v) WHERE id=$k") or die('Error');
}
Basically,
1. Use arrays for your forms and identify the key as your table's primary key
2. Loop through the arrays you made for your form, and use the key as your WHERE clause.





Reply With Quote