This is in reference to the post made here: insert multiple rows via a php array into mysql
My question is, can anyone explain this in more detail? I dont understand what $data
and what $row
is or does.
I'm pulling in many variables from a form like: $Customer = $_POST['Customer'];
So if someone can show an example of how to use this code with multiple variables, it would be real nice.
$sql = array();
foreach( $data as $row )
{
$sql[] = '("'.mysql_real_escape_string($row['text']).'", '.$row['category_id'].')';
}
mysql_query('INSERT INTO table (text, category) VALUES '.implode(',', $sql));