Here is my code. It is insert only last element value. I want to insert all value in one field with different id and all data insert in different different row.
Change your sql for insert into this :
function mysql_insert_multiple($db, $table, $columns) {
$sql = "INSERT INTO `" . $table . "` ";
// implode keys of $array...
$sql .= " (`" . implode("`, `", array_keys($columns[0])) . "`)";
// implode values of $array...
$sql .= " VALUES ";
$tempstr = array();
foreach ($columns as $row) {
$tempstr[] = " ('" . implode("', '", array_values($row)) . "') ";
$sql.=implode(',', $tempstr);
$sql.=";";
$result = mysql_query($sql, $db) or die(mysql_error());
}
return $result;
}
This will work if your $column array is in the format:
$columns = array(
0 => array("name" => 'slider'
"value" => $user_slider.
1 =>
.
.
.
So I think you need to change your $column array as well.
You can user your query with in a loop to insert the multiple recoded in a field at a time.