/ Published in: PHP
Inserts the values of an array into a table. Also supports specifying if a specific field needs to be encoded using PASSWORD()
Parameters:
Table: Name of table to insert into
Data: array of $field->$value of new data
Password Field: Which field in the data array needs to be surrounded with PASSWORD() (optional)
Parameters:
Table: Name of table to insert into
Data: array of $field->$value of new data
Password Field: Which field in the data array needs to be surrounded with PASSWORD() (optional)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function mysql_insert_array($table, $data, $password_field = "") { foreach ($data as $field=>$value) { $fields[] = '`' . $field . '`'; if ($field == $password_field) { } else { } } $query = "INSERT INTO `" . $table . "` (" . $field_list . ") VALUES (" . $value_list . ")"; return $query; }
URL: http://snippets.dzone.com/posts/show/4350