Jump to: navigation, search

Php oop product management product delete

From w3cyberlearnings

Contents

Objective

Create a delete page to delete product based on the product id.

delete.php

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Delete</title>
	</head>
	<body>
		<?php
		require_once 'product.php';
		if (isset($_REQUEST['id'])) {
			$product = new product();
			$product->id = $_REQUEST['id'];

			// get product for display later 
			$product_infor = $product->get_product_by_id();

			if ($product->delete_db()) {
				echo '<h3>Successfully deleted:';
				echo  $product_infor[0]['pname'] . '</h3>';
			} else {
				echo '<h3>Error delete product info</h3>';
			}
		}

		require_once 'menu.php';
		?>
	</body>
</html>

Print Screen

Php oop product management product delete.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