Jump to: navigation, search

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>

Print Screen

Php oop product management product detail.png

Related Links


  1. Chapter 1: Singleton class
  2. Chapter 2: Table
  3. Chapter 3: Product Class
  4. Chapter 4: Add Product
  5. Chapter 5: Activity Menu
  6. Chapter 6: List All Products
  7. Chapter 7: Product Detail
  8. Chapter 8: Update or Edit Product
  9. Chapter 9: Delete Product
Navigation
Web
SQL
MISC
References