Php oop product management product detail
From w3cyberlearnings
Contents |
Objective
Display product detail based on the product id.
detail.php
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Detail</title> </head> <body> <?php // include the product file require_once 'product.php'; // get product id if (isset($_REQUEST['id'])) { $product = new product(); // create product object $product->id = $_REQUEST['id']; // assign product id $product1 = $product->get_product_by_id(); // call function to get product echo '<table border="0" cellspacing="5" cellpadding="4">'; // create product detail foreach ($product1 as $pro) { foreach ($pro as $k => $v) { echo '<tr>'; echo '<td>' . ucfirst($k) . '</td>'; echo '<td>' . $v . '</td>'; echo '</tr>'; } } echo '</table>'; } else { echo 'error!'; } // include menu require_once 'menu.php'; ?> </body> </html>