Advertisement
arijulianto

Simpan Multipel dengan PHP

Jun 10th, 2014
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. <?php
  2. $mysqli = new mysqli('localhost', 'root', '', 'mydatabase');
  3. $n = 0;
  4. foreach($_POST['nama'] as $i=>$nama){
  5.     // parse data
  6.     $nama = $mysqli->escape_string($nama);
  7.     $job = $mysqli->escape_string($_POST['job'][$i]);
  8.     $kota = $mysqli->escape_string($_POST['kota'][$i]);
  9.     $phone = $mysqli->escape_string($_POST['phone'][$i]);
  10.     // proses simpan
  11.     $save = $mysqli->query("INSERT into tbldata(nama,job,kota,phone) VALUES('$nama','$job','$kota','$phone')");
  12.     if($save)
  13.         $n = $n+1;
  14. }
  15.  
  16. if($n>0){
  17.     echo "Data berhasil disimpan...";
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement