function modifyTopic() { $TopicId = (int) $_GET['TopicId']; $catId = $_POST['cboCategory']; $name = $_POST['txtName']; $description = $_POST['mtxDescription']; $price = str_replace(',', '', $_POST['txtPrice']); $qty = $_POST['txtQty']; $images = uploadTopicImage('fleImage', SRV_ROOT . 'images/Topic/'); $mainImage = $images['image']; $thumbnail = $images['thumbnail']; // if uploading a new image // remove old image if ($mainImage != '') { _deleteImage($TopicId); $mainImage = "'{$mainImage}'"; $thumbnail = "'{$thumbnail}'"; } else { // if we're not updating the image // make sure the old path remain the same // in the database $mainImage = 'pd_image'; $thumbnail = 'pd_thumbnail'; } $sql = "UPDATE tbl_Topic \r\n\t SET cat_id = {$catId}, pd_name = '{$name}', pd_description = '{$description}', pd_price = {$price}, \r\n pd_qty = {$qty}, pd_image = {$mainImage}, pd_thumbnail = {$thumbnail}, pd_last_update = NOW()\r\n\t\t\t WHERE pd_id = {$TopicId}"; $result = dbQuery($sql); header('Location: index.php'); }
function deleteImage() { if (isset($_GET['productId']) && (int) $_GET['productId'] > 0) { $productId = (int) $_GET['productId']; } else { header('Location: index.php'); } $deleted = _deleteImage($productId); // update the image and thumbnail name in the database $sql = "UPDATE tbl_product\n\t\t\tSET pd_image = '', pd_thumbnail = ''\n\t\t\tWHERE pd_id = {$productId}"; dbQuery($sql); header("Location: index.php?view=modify&productId={$productId}"); }
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\n\t\t\tSET cat_image = ''\n\t\t\tWHERE cat_id = {$catId}"; dbQuery($sql); header("Location: index.php?view=modify&catId={$catId}"); }