I have a problem while inserting multiple record in to the db
HTML
<input type="input" name="row[][name]">
<input type="input" name="row[][surname]">
<input type="input" name="row[][name]">
<input type="input" name="row[][surname]">
PHP
$returnedData = $_POST['row'];
$sql = array();
foreach( $returnedData as $row ) {
$sql[] = '("'.mysql_real_escape_string($row['name']).'", '.mysql_real_escape_string($row['surname']).')';
}
mysql_query('INSERT INTO tableName (name, surname) VALUES '.implode(',', $sql));
But the error is It opens 4 rows while I mean it opens a new row for each input.
How can I insert two records ?
NEW INFO
when I write posted values by usingforeach I can see the values properly, the thing is I couldnt find the solution to insert in to my table
foreach($returnedData as $data) {
echo '<pre>';
echo $data['name'];
echo $data['surName'];
}