Created
June 15, 2014 12:34
-
-
Save ruliarmando/be885c1b4601a063c7f4 to your computer and use it in GitHub Desktop.
insert using array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function insert($table, $fields, $data) | |
{ | |
$SQL = "INSERT INTO {$table} (".implode(', ', $fields).") VALUES (".implode(', ', array_intersect_key($data, array_flip($fields))).")"; | |
echo $SQL; | |
// lanjutkan peng-query-an disini | |
} | |
insert('mahasiswa', array('nim', 'nama', 'jk'), array('nim'=>'1088', 'nama'=>'andi', 'jk'=>'l', 'alamat'=>'jln.sendok')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment