Advertisement
xhaosmaster

Untitled

Dec 9th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.60 KB | None | 0 0
  1. <?php
  2. require_once("include/database.php");
  3.  
  4. $stm = $db->prepare("SELECT cat.categoryName, AVG(c.ListPrice)
  5. FROM categories cat, cars c
  6. WHERE cat.category_id = c.category_id
  7. GROUP BY cat.categoryName;");
  8. $stm->execute();
  9. $displayQuery = $stm->fetchAll();
  10. ?>
  11. <!DOCTYPE html>
  12. <html>
  13.     <head>
  14.         <meta charset="UTF-8">
  15.         <title></title>
  16.     </head>
  17.     <body>
  18.         <?php foreach($displayQuery as $query) :?>
  19.         <div>Category: <?php echo $query["categoryName"]; ?> <br> Average : $<?php echo $query["AVG(c.ListPrice)"]; ?></div>
  20.         <?php endforeach; ?>
  21.     </body>
  22. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement