Guest User

Untitled

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