This is my php array
$j_obj = Array
(
[Cluster] => 1
[Cost] => 48
[Conversions] => 20
[MyColumn] => 45
)
Array
(
[Cluster] => 1
[Cost] => 46
[Conversions] => 20
[MyColumn] => 37
)
Array
(
[Cluster] => 1
[Cost] => 47
[Conversions] => 19
[MyColumn] => 40
)
The above json array is not static one,it comes dynamically.
I need to insert the array values in mysql insert query.I try the following
foreach ($j_obj as $row)
{
print_r(implode(',', $row));
//$sql = "insert into $tbl_name values(implode(',', $row))";
// I got this value from printing the $row
//1,48,20,451,46,20,371,47,19,401,51,6
what my need is
//$sql = "insert into $tbl_name values(1,48,20,451),(46,20,371,47),(19,401,51,6)";
}
The table and columns are also created dynamically from json value,
Can anybody help me ?