<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <script src='js/main.js'></script> </head> <body> <?php include './menu.php'; require 'pages.php'; ?> <table> <tr> <th>Product</th> <th>Price</th> <th></th> </tr> <?php function displayProduct($row) { echo "<tr>\n <td>" . $row["product_name"] . "</td>\n <td>" . $row["product_price"] . "</td>\n <td><input type='button' value='Add'\n onclick='basket_add(" . $row["product_id"] . ")'>\n </td>\n <td><a href='/products?id=" . $row["product_id"] . "'>\n <button>More info</button></a>\n </td>\n </tr>"; } require 'product_list.php'; displayProductList('displayProduct'); ?> </table> <?php require 'pages.php'; ?> <p id="responseText"></p> </body> </html>
<?php require_once 'config.php'; $h1 = '<em>Welcome to ACME Widget Company</em>'; $h2 = 'Product List'; include 'header.html'; function displayProductList() { global $products; echo '<dl>'; foreach ($products as $product) { echo '<dt>' . $product->getName() . '</dt>'; echo '<dd>$' . number_format($product->getPrice(), 2); // TODO : use http_build_query() echo ' <a href="cart.php?action=addItem&productId=' . $product->getId() . '">Add To Cart</a></dd>'; } echo '</dl>'; } displayProductList(); include 'show_cart.html'; include 'footer.html';