Skip to end of metadata
Go to start of metadata

Technically you cannot insert array values into MySQL database table directly without understanding its data type correctly. If it's data type is all the same, you can implement it by array_keys()

Below is a standard MySQL insert statement:

insert into table1(column1, column2, ...) values(value1, value2,...)


If all the data type defined in the table is numeric, it can be implemented like below:

$columns = implode(", ",array_keys($insData));
$escaped_values = array_map('mysql_real_escape_string', array_values($insData));
$values  = implode(", ", $escaped_values);
$sql = "INSERT INTO `fbdata`($columns) VALUES ($values)";

Note PHP 5.5 mysql_real_escape_string has been deprecated and as of PHP7 it has been removed, so you need to find another way for escape string.