Advertisement
Benvu

importcsv.php

Feb 28th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <?php
  2. include 'dbconfig.php';
  3.  
  4. if(isset($_POST['submit']))
  5. {
  6.  
  7. $file = $_FILES['file']['tmp_name'];
  8.  
  9. $handle = fopen($file,"r");
  10.  
  11. while (($filecsv = fgetcsv($handle,1000,",")) !==false)
  12. {
  13. $tanggal = $filecsv[0];
  14. $waktu = $filecsv[1];
  15. $waktu_berakhir = $filecsv[2];
  16. $camera = $filecsv[3];
  17. $counter = $filecsv[4];
  18. $result = $filecsv[5];
  19. $sql =mysql_query("INSERT INTO csv_coba (tanggal,waktu,waktu_berakhir,camera,counter,result) VALUES (
  20. '$tanggal','$waktu','$waktu_berakhir','$camera','$counter','$result') ");
  21. }
  22.  
  23.  
  24. }
  25.  
  26. ?>
  27.  
  28. <html lang= en>
  29. <head>
  30. <meta charset="utf-8">
  31. <title>test</title>
  32. </head>
  33. <body>
  34. <form method="post" action="import.php" enctype="multipart/form-data">
  35. <input type="file" name="file"/>
  36. <br>
  37. <input type="submit" name="submit" value="Submit">
  38. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement