Print_r ($ dbinsert:
Array
(
[0] => Array
(
[Apmac] => 0q: 4e: cb: 00: 01: 09
[Pub_ip] => 11.24.24.7
[Priv_ip] => 12.18.1.3
[Hwver] => VA500
[Fwver] => 69.0.0
[Vsmip] => 12.25.1.19
[Conntime] = & gt; 677822
[Boottime] = & gt; 49950
[State] =>
[Statetime] =>
[Hostname] => name1
[Location] => 0004.003.01
[Admin_id] => 0
)
[1] => Array
(
[Apmac] => 10: qe: cv: 02: 00: 37
[Pub_ip] => 11.24.24.7
[Priv_ip] => 12.18.1.3
[Hwver] => VA500
[Fwver] => 69.0.0
[Vsmip] => 12.25.1.19
[Conntime] = & gt; 169547
[Boottime] = & gt; 403315
[State] =>
[Statetime] =>
[Hostname] => nam2
[Location] => 0004.003.01
[Admin_id] => 0
)
[2] => Array
(
[Apmac] => r0: ve: cb: 00: ff: 04
[Pub_ip] => 13.24.28.7
[Priv_ip] => 92.18.1.18
[Hwver] => V
[Fwver] => 6 .)
[Vsmip] => 12.25.1.79
[Conntime] = & gt; 168
[Boottime] = & gt; 144497
[State] =>
[Statetime] =>
[Hostname] => name5
[Location] => 0004.003.01
[Admin_id] => 0
)
)
Problem:
I want to insert the content into table 3 of the database table. the table structure is the same as the returned content and the order is the same.
How can I write a php program?
Reply to discussion (solution)
$ F = ''; $ v = array () foreach ($ dbinsert as $ row) {if (empty ($ f) $ f = join (',', $ array_key ($ row); $ v [] = "('". join ("','", $ row ). "')";} $ SQL = "insert into table3 ($ f) values ". join (',', $ v); // execute the $ SQL statement.
$ F = ''; $ v = array () foreach ($ dbinsert as $ row) {if (empty ($ f) $ f = join (',', $ array_key ($ row); $ v [] = "('". join ("','", $ row ). "')";} $ SQL = "insert into table3 ($ f) values ". join (',', $ v); // execute the $ SQL statement.
Sorry .... Is it easy to write popular data without considering efficiency and introduction?
1. traverse the two-dimensional array and combine the elements in the array into a string (using a number in the middle) to form an inset string.
I don't understand this?
2. combine the above strings and SQL statements into inset statements and add them cyclically.
The version is awesome. I just want to translate it.
Notice: Undefined variable: array_key in Dex3.php on line 19 Fatal error: Function name must be a string in Dex3.php on line 19
19 if (empty ($ f) $ f = join (',', $ array_key ($ row ));
If (empty ($ f) $ f = join (',', array_keys ($ row ));
1. traverse the two-dimensional array and combine the elements in the array into a string (using a number in the middle) to form an inset string.
I don't understand this?
2. combine the above strings and SQL statements into inset statements and add them cyclically.
The version is awesome. I just want to translate it.
It's really a third brother, smart