PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php function placeholders($text, $count = 0, $separator = ",") { $result = array(); if ($count > 0) { for ($x = 0; $x < $count; $x++) { $result[] = $text; } } return implode($separator, $result); } foreach ($data as $d) { $question_marks[] = '(' . placeholders('?', sizeof($d)) . ')'; } $sql = "INSERT INTO table (" . implode(",", array_keys($datafield)) . ") VALUES " . implode(',', $question_marks); echo $sql
Show:  
Copy Clear