[php] كود ادخال كم كبير من البيانات بالقاعدة باستعلام واحد فقط

<?php
// include the database
include 'db.php';
$query = 'INSERT INTO `table_name` (`ownerID`, `favorites`) VALUES ';
// This foreach we will pretend that we passed an array of
// checkboxs, which could be our favorite food for this example.
foreach($_POST['favorites'] as $box){
$b = mysql_real_escape_string($box); // Safe query string
$query .= "('{$_SESSION['id']}', '$b'),";
}
// Remove the trailing comma at the end.
$query = trim($query,',');
// Perform the query
mysql_query($query);
?>

تعليقات