AlessandroCaputo

get_record.php

Apr 27th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "root";
  5. $dbname = "prodotti";
  6.  
  7. //Create connection
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9.  
  10. //Check connection
  11. if ($conn->connect_error) {
  12. die("Connessione fallita: " . $conn->connect_error);
  13. }
  14.  
  15. $sql = "SELECT * FROM lista_prodotti";
  16. $result = $conn->query($sql);
  17.  
  18. $row = $result->fetch_assoc();
  19.  
  20. echo '
  21. <div id="table">
  22. <table border="1" cellpadding="3">
  23. <colgroup>
  24. <col span="3" width="250px">
  25. </colgroup>
  26.  
  27. <thead>
  28. <tr>
  29. <th><strong>Nome Prodotto</strong></th>
  30. <th><strong>Quantità</strong></th>
  31. <th><strong>Scadenza</strong></th>
  32. </tr>
  33. </thead>
  34. </table>';
  35.  
  36. while ($row = $result->fetch_assoc()) {
  37. echo '
  38. <table border="1" cellpadding="3">
  39. <colgroup>
  40. <col span="3" width="250px">
  41. </colgroup>
  42.  
  43. <tbody>
  44. <tr>
  45. <td>' . $row["nome_prodotto"] . '</td>
  46. <td>' . $row["quantita"] . '</td>
  47. <td>' . $row["scadenza"] . '</td>
  48. </tr>
  49. </tbody>
  50. </table>
  51. </div>
  52. ';}
  53.  
  54. $conn->close();
  55. ?>
Add Comment
Please, Sign In to add comment