Я не уверен, что вы имеете в виду.Но ваш HTML-код должен выглядеть примерно так:
<p>
<input type="text" name="persons[][name]">
<input type="text" name="persons[][email]">
<input type="text" name="persons[][organisation]">
<input type="text" name="persons[][position]">
</p>
И затем в конце вашего PHP-скрипта
$values = array();
foreach ($_POST['persons'] as $person) {
// Sanitize your datas
...
// SQL VALUES TO INSERT
$values[] = '(' . $person['name'] . ',' . $person['email'] . ',' . $person['organisation'] . ',' . $person['position'] . ')';
}
$query = "INSERT INTO person (name, email, organization, position) VALUES " . implode(',', $values);
Та же логика применяется к тарифам без оплаты
измените, если хотите сохранить свой HTML
$values = array();
for($i = 0; $i < $row_count; $i++) {
// variable sanitation...
$name = trim(stripslashes($_POST['name'][$i]));
$email = trim(stripslashes($_POST['email'][$i]));
$organisation = trim(stripslashes($_POST['organisation'][$i]));
$position = trim(stripslashes($_POST['position'][$i]));
// this assumes name, email, and telephone are required & present in each element
// otherwise you will have spurious line breaks.
$body .= "Name: " . $name . " Email: " . $email . " Organisation: " . $organisation . " Position: " . $position . "\n\n";
//prepare the values for MySQL
$values[] = '(' . $name . ',' . $email . ',' . $organisation . ',' . $position . ')';
}
$query = "INSERT INTO person (name, email, organization, position) VALUES " . implode(',', $values);
And for unwaged rate
$values = array();
for($i = 0; $i < $row_count; $i++) {
// variable sanitation...
$name = trim(stripslashes($_POST['name'][$i]));
$email = trim(stripslashes($_POST['email'][$i]));
// this assumes name, email, and telephone are required & present in each element
// otherwise you will have spurious line breaks.
$body .= "Name: " . $name . " Email: " . $email . "\n\n";
//prepare the values for MySQL
$values[] = '(' . $name . ',' . $email . ')';
}
$query = "INSERT INTO person (name, email) VALUES " . implode(',', $values);