Created
November 14, 2015 13:19
-
-
Save dwihujianto/3f851ee631d0b01e64a4 to your computer and use it in GitHub Desktop.
Multifield update
This file contains hidden or 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
<pre> | |
<form action="post.php" method="POST"> | |
Kode <input type="text" name="_id[]"> | |
Nama <input type="text" name="_nama[]"> | |
Kode <input type="text" name="_id[]"> | |
Nama <input type="text" name="_nama[]"> | |
Kode <input type="text" name="_id[]"> | |
Nama <input type="text" name="_nama[]"> | |
<input type="submit" value="simpan"> | |
</form> | |
</pre> |
This file contains hidden or 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 | |
$id = $_POST['_id']; | |
$nama = $_POST['_nama']; | |
$data = array_combine($id, $nama); | |
$sql = null; | |
foreach ($data as $key => $value) { | |
$sql .="UPDATE table SET nama = ".$value." WHERE id = ".$key; | |
} | |
echo $sql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment