I had these replies form mwolfe & stereofrog on another forum and thought I'd share them. They have both helped me out bigtime. I managed to alter mwolfe's code slightly to get a result:
PHP Code:
$make = $POST['make'];
$model = $POST['model'];
$year = $_POST['year_install'];
$amount = count($make);
$sql = "INSERT INTO machines (machines_id,customers_id,make,model,year_install) VALUES ";
$amount = count($make);
for ($i=0; $i < $amount; $i++) {
$currMake = $make[$i];
$currModel = $model[$i];
$currYear = $year[$i];
$sql .= "('', '$cust_id', '$currMake', '$currModel', '$currYear-01-01'),";
}
$sql = substr_replace($sql,"",-1); //remove the last comma
However, I really like stereofrog's code as it looks neater...I just don't understand what's going on there...I'll have to look it up:
PHP Code:
if(isset($REQUEST['go'])) {
$sql = array();
foreach($REQUEST['r'] as $row) {
$sql[] = sprintf("('%s', '%s', %d)",
mysql_real_escape_string($row['model']),
mysql_real_escape_string($row['make']),
intval(@$row['order'])
);
}
$sql = implode(", ", $sql);
$sql = "INSERT INTO tbl(make,model,order) VALUES $sql";
echo "<div>$sql</div>";
// mysql_query stuff here
}
There are not multiple checkboxes, so I'm ok with the javascript I already have...plus I'm not too hot on javascript, having only started reading Stuart Langridge's DHTML book this week: http://www.sitepoint.com/books/dhtml1/.
Now I'm onto my next task...implementing a email verification system...I presume I'll have to include a link with some sort of identifier...maybe hashed...any ideas?