Advertisement
Guest User

Untitled

a guest
Sep 16th, 2017
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "localhost";
  4. $username = "root";
  5. $password = "";
  6. $db = "meniu";
  7.  
  8. $err = "";
  9.  
  10. // Create connection
  11. $conn = mysqli_connect($servername, $username, $password, $db);
  12.  
  13. // Check connection
  14. if (!$conn) {
  15. die("Connection failed: " . mysqli_connect_error());
  16. }
  17. mysqli_set_charset($conn, "utf8");
  18.  
  19. //echo "Connected successfully<br >";
  20. $sql = "SELECT * FROM patiekalai ORDER BY id";
  21.  
  22. $result = mysqli_query($conn, $sql);
  23.  
  24.  
  25.  
  26. $patiekalai = [];
  27.  
  28. if (mysqli_num_rows($result) > 0) {
  29.  
  30. while($row = mysqli_fetch_assoc($result)) {
  31. array_push($patiekalai, $row);
  32. }
  33.  
  34. } else {
  35. $err = "Patiekalų nerasta";
  36. }
  37.  
  38. mysqli_close($conn);
  39.  
  40. include "view.php";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement