Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once("include/database.php");
- $stm = $db->prepare("SELECT cat.categoryName, AVG(c.ListPrice)
- FROM categories cat, cars c
- WHERE cat.category_id = c.category_id
- GROUP BY cat.categoryName;");
- $stm->execute();
- $displayQuery = $stm->fetchAll();
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title></title>
- </head>
- <body>
- <?php foreach($displayQuery as $query) :?>
- <div>Category: <?php echo $query["categoryName"]; ?> <br> Average : $<?php echo $query["AVG(c.ListPrice)"]; ?></div>
- <?php endforeach; ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement