4zmy

import

Apr 20th, 2015
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.28 KB | None | 0 0
  1. <?php
  2. include "../../config/koneksi.php";
  3. require_once 'excel/excel_reader2.php';
  4. $data = new Spreadsheet_Excel_Reader();
  5. $data->setOutputEncoding('CP1251');
  6.  
  7. // Ambil Value Dari Inputan Form
  8. $data = new Spreadsheet_Excel_Reader($_FILES['dataku']['name']);
  9. $baris = $data->rowcount($sheet_index=0);
  10.  
  11. for ($x=2; $x <= count($data->sheets[0]["cells"]); $x++) {
  12.     // Mendefinisikan Shell dalam File Excel Sejumlah Field yang ada di tabel
  13.     $nim = $data->sheets[0]["cells"][$x][1];
  14.  $nama_mahasiswa = $data->sheets[0]["cells"][$x][2];
  15.     $tempat_lahir = $data->sheets[0]["cells"][$x][3];
  16.  $tanggal_lahir = $data->sheets[0]["cells"][$x][4];
  17.  $alamat = $data->sheets[0]["cells"][$x][5];
  18.     $no_hp = $data->sheets[0]["cells"][$x][6];
  19.  $jenis_kelamin = $data->sheets[0]["cells"][$x][7];
  20.  $angkatan = $data->sheets[0]["cells"][$x][8];
  21.     $idgroup = $data->sheets[0]["cells"][$x][9];
  22.  $kd_prodi = $data->sheets[0]["cells"][$x][10];
  23.  // Simpan Ke Tabel
  24.     $simpan = mysql_query("INSERT INTO mahasiswa  VALUES ('$nim','$nama_mahasiswa','$tempat_lahir','$tanggal_lahir','$alamat','$no_hp','$jenis_kelamin','$angkatan','$idgroup','$kd_prodi')");
  25.  if (!$simpan){
  26.  echo "Data Ke ".$x." GAGAL disimpan!";
  27.  }
  28. }
  29. echo "<script>alert('Data Berhasil di Import!'); history.go(-1);</script>";
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment