Admin - Edit Category
This page is where you can modify a category information. You can see that the form is just a lame copy from add.php. The difference is that in this page we need to fetch the category information first so we can show it in the input boxes.
Another difference is that in this form we also display the category image. If you change the category image then the old image will be deleted from the server and the new image is uploaded. Take a look a the code below. To get the category info from database we need the category id from the query string. If $_GET['catId'] is not present or empty we just redirect to index.php. If it's present and not empty we fetch the category info. |
|
Source code : admin/category/modify.php <?php
if (!defined('WEB_ROOT')) { exit; } // make sure a category id exists // ... put the form down here On the screenshot you can see that we next to the category image we have a delete link. Clicking on the link will call the javascript function deleteImage(). This function will pop a confirmation box and if you confirm the deletion the function will redirect you to processCategory.php where all category related process is taken care of. Below is the code that perform the image deletion Source code : admin/category/processCategory.php function deleteImage()
{ if (isset($_GET['catId']) && (int)$_GET['catId'] > 0) { $catId = (int)$_GET['catId']; } else { header('Location: index.php'); } _deleteImage($catId); // update the image name in the database $sql = "UPDATE tbl_category SET cat_image = '' WHERE cat_id = $catId"; dbQuery($sql); header("Location: index.php?view=modify&catId=$catId"); } To delete the image from the server the deleteImage() function calls _deleteImage(). Please excuse this lame function naming. I just cant' find other name that fit perfectly for this function. After deleting the image we update the category information in database. We only need to set cat_image to an empty string and we're done. The final thing that deleteImage() do is redirect back to the category modification page. We don't redirect to category listing page because the admin may still want to modify the category further. |
|
|
|
|
Admin - Add Category | PHP MySQL Shopping Cart Tutorial : Admin - Edit Category | Admin - Delete Category |
|
At long last i'm finally able to update this site. Now the shopping cart can handle payment through paypal. As always you have any critiques, questions, comments or problems about this tutorial please tell me. Click here to send your feedback. And if you like this tutorial please link to this site. It will really help a lot :-) |
PHP MySQL Shopping Cart Tutorial
Copyright © 2005 - 2008 www.phpwebcommerce.com