Guest User

Untitled

a guest
Dec 8th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <!--
  3. To change this license header, choose License Headers in Project Properties.
  4. To change this template file, choose Tools | Templates
  5. and open the template in the editor.
  6. -->
  7. <html>
  8. <head>
  9. <meta charset="UTF-8">
  10. <title></title>
  11. </head>
  12. <body>
  13. <?php
  14.  
  15. include 'connect.php';
  16. $stmt = $DB_con->prepare('SELECT car_name,car_fuel,car_engineSize,car_color FROM motor_vehicles ORDER BY car_ID DESC');
  17. $stmt->execute();
  18.  
  19. if($stmt->rowCount() > 0)
  20. {
  21. echo '<ol>';
  22. while($row=$stmt->fetch(PDO::FETCH_ASSOC))
  23. {
  24.  
  25. echo '<li>';
  26. echo $row['car_name','car_fuel','car_engineSize','car_color'].' '.$row['car_ID'];
  27.  
  28. echo '</li>';
  29. }
  30. echo '</ol>';
  31. }
  32.  
  33. ?>
  34. </body>
  35. </html>
  36.  
  37. <?php
  38.  
  39. /*
  40. * To change this license header, choose License Headers in Project Properties.
  41. * To change this template file, choose Tools | Templates
  42. * and open the template in the editor.
  43. */
  44. $DB_HOST = 'localhost';
  45. $DB_USER = 'root';
  46. $DB_PASS = '';
  47. $DB_NAME = 'motor_vehicles';
  48.  
  49. try {
  50. $DB_con = new PDO("mysql:host={$DB_HOST};dbname={$DB_NAME}", $DB_USER, $DB_PASS);
  51. $DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  52. } catch (PDOException $e) {
  53. echo $e->getMessage();
  54. }
Add Comment
Please, Sign In to add comment