Advertisement
Guest User

filip

a guest
Dec 5th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. </head>
  6. <body>
  7. <?php
  8. $servername="localhost";
  9. $username="root";
  10. $password="";
  11. $dbname="ohayov3";
  12.  
  13. $conn=mysqli_connect($servername,$username,$password,$dbname);
  14. if($conn)
  15. {
  16.  
  17. $wiersze=file('filmy.txt');
  18. $n=count($wiersze);
  19. for($i=0; $i<$n; $i++)
  20. {
  21. $tab=explode("\t",$wiersze[$i]);
  22. for($o=0; $o<5; $o++)
  23. {
  24. $tab[$o]=trim($tab[$o]);
  25. }
  26.  
  27.  
  28.  
  29.  
  30.  
  31. $sql = "INSERT INTO filmy (`ID`,`ID_filmu`,`Tytul`,`Kraj_produkcji`,`Gatunek`,`Cena_w_zl`) VALUES (NULL, '".$tab[0]."', '".$tab[1]."', '".$tab[2]."', '".$tab[3]."', '".$tab[4]."');";
  32. mysqli_query($conn, $sql);
  33. }
  34.  
  35.  
  36. }
  37. else
  38. {
  39. die("Błąd połączenia : " . mysqli_connect_error());
  40. }
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48. mysqli_close($conn);
  49. ?>
  50. </body>
  51. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement