asked on
<?php
require_once('database.php');
// Get all categories
$query = 'SELECT * FROM categories
ORDER BY categoryID';
$categories = $db->query($query);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- the head section -->
<head>
<title>My Guitar Shop</title>
<link rel="stylesheet" type="text/css" href="main.css" />
</head>
<!-- the body section -->
<body>
<div id="page">
<div id="header">
<h1>Product Manager</h1>
</div>
<div id="main">
<h1>Category List</h1>
<table>
<tr>
<th>Name</th>
<th> </th>
</tr>
<!-- add code for the rest of the table here -->
<?php foreach($categories as $cat) : ?>
<tr>
<td><?php echo $cat['categoryName']; ?></td>
<td>
<form action="delete_category.php" method="post" id="delete_cat_form">
<input type="hidden" name="catID"
value="<?php echo $cat['categoryID']; ?>"/>
<input type="submit" value="Delete "
</form>
</td>
</tr>
<?php endforeach; ?>
</table>
<br />
<h2><a href="add_category_form.php">Add Category</a></h2>
<!-- add code for the form here -->
<br />
<p><a href="index.php">List Products</a></p>
</div> <!-- end main -->
<div id="footer">
<p>
© <?php echo date("Y"); ?> My Guitar Shop, Inc.
</p>
</div>
</div><!-- end page -->
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- the head section -->
<head>
<title>My Guitar Shop</title>
<link rel="stylesheet" type="text/css" href="main.css" />
</head>
<!-- the body section -->
<body>
<div id="page">
<div id="header">
<h1>Product Manager</h1>
</div>
<div id="main">
<h1>Category List</h1>
<table>
<tr>
<th>Name</th>
<th> </th>
</tr>
<!-- add code for the rest of the table here -->
<tr>
<td>Guitars</td>
<td>
<form action="delete_category.php" method="post" id="delete_cat_form">
<input type="hidden" name="catID"
value="1"/>
<input type="submit" value="Delete "
</form>
</td>
</tr>
<tr>
<td>Basses</td>
<td>
<form action="delete_category.php" method="post" id="delete_cat_form">
<input type="hidden" name="catID"
value="2"/>
<input type="submit" value="Delete "
</form>
</td>
</tr>
<tr>
<td>Drums</td>
<td>
<form action="delete_category.php" method="post" id="delete_cat_form">
<input type="hidden" name="catID"
value="3"/>
<input type="submit" value="Delete "
</form>
</td>
</tr>
</table>
<br />
<h2><a href="add_category_form.php">Add Category</a></h2>
<!-- add code for the form here -->
<br />
<p><a href="index.php">List Products</a></p>
</div> <!-- end main -->
<div id="footer">
<p>
© 2014 My Guitar Shop, Inc.
</p>
</div>
</div><!-- end page -->
</body>
</html>
<?php
$cat = $_POST['catID'];
$query = "cat = $cat";
echo $query;
?>