You could use the REPLACE SQL command with multiple input sets, something like:
REPLACE INTO table_name (`col1`, `col2`, `col3`)
VALUES ('val11', 'val12', 'val13'), ('val21', 'val22', 'val23'), ('val31', 'val32', 'val33')
The above would insert 3 rows of 3 columns, replacing any existing rows which have the same value for any primary key or unique index columns.
So if you could grab the inputs from your form page and create a 2-dim array of values...
$myArray:
Array
(
[0] => Array
(
[col1] => val11
[col2] => val12
[col3] => val13
)
[1] => Array
(
[col1] => val21
[col2] => val22
[col3] => val23
)
[2] => Array
(
[col1] => val31
[col2] => val32
[col3] => val33
)
)
...then you could implode everything together into your value expression:
$values = "";
foreach($myArray as $data)
{
$values = "('" . implode("','", $data) . "'),";
}
$values = trim($values, ','); // get rid of trailing comma
$query = "REPLACE INTO table_name ('col1', 'col2', 'col3') VALUES $values";