Your form:
Code:
<form action=update.php method=post>
// pseudocode ish
foreach vehicle with no color{
<p>Make is: plymouth<br />
Model Type: SUV<br />
What color is it? <input type=text name="7" value=""></p>
}
// close off your single form
<input type=submit>
</form>
Your postback form handler
update.php
PHP Code:
<?php
// check what is passed back to this handler
var_dump($_POST);
unset($_POST['submit']); // get rid of submit button
var_dump($_POST); // check that worked, is submit gone?
// now update your db
foreach($_POST as $k=>$val){
// escape the string to avoid sql injection, and turn a numerical id into an integer (or set to 0 on fail)
$sql = "update cars set color = '". mysql_real_escape_string($_POST[$k]). "' where id=" . (int)$k;
// send query to dbase here
}
Not tested, but in theory this is one way you could do it.
It is possible to update all cars with one query but that should get you going.
Bookmarks