<?
// *******************************************************************
// admin/delete_category.php
// Reworked variables to add a Confirm deletion - DSB 5-3-04
// *******************************************************************
include("../include/config.php");
include("../include/functions.php");
include("../include/lang/$language.php");
include("../include/common.php");
include("../include/session.php");
session_start();
//
$ID=$_GET['ID'];
if (empty($ID)){$ID=$_POST['ID'];}
if (!empty($_GET['RPID'])) {
$RPID=$_GET['RPID'];
}
if (!empty($_POST['update'])) {
$update = $_POST['update'];
}
//added - DSB
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<link rel = "stylesheet" type = "text/css" href = "style.css" />
</head><?
//echo "<META NAME=\"REFRESH\" HTTP-EQUIV=\"REFRESH\" ";
//echo "content=\"2; URL=categories_main.php?" . session_name() . "=";
//echo session_id() . "&RPID=" . $RPID . "\">";
?>
<?=$adm_body?>
<table cellspacing="0" cellpadding="5" border="1" align="center" width="100%">
<tr>
<td align="center" class="theader"><?
//
if(isset($RPID)){
$get_cat = sql_query("
select
*
from
$tb_categories
where
ID='$RPID'
");
$get_row = sql_fetch_array($get_cat);
$delete = sql_query("
delete from
$tb_categories
where
ID='$RPID'
");
echo "<br />Category " . $get_row[Category];
echo " has been deleted.<br /><br />";
echo "<a href=\"categories_main.php?" . session_name() . "=";
echo session_id() . "&PID=0";
echo "\">Click here to continue</a><br /><br />";
}// changed from $ID to $RPID for deletion after confirm
if(isset($ID)){
$get_cat = sql_query("
select
*
from
$tb_categories
where
ID='$ID'
");
$get_row = sql_fetch_array($get_cat);
$check_for_child = sql_query("
select
*
from
$tb_categories
where
PID='$get_row[ID]'
");
$count_parent_row = sql_num_rows($check_for_child);
if($count_parent_row > 0){
echo "<br />Cannot delete " . $get_row[Category];
echo ", you must<br>delete it's subcategories first.<br /><br />";
echo "<a href=\"categories_main.php?" . session_name() . "=";
echo session_id() . "&PID=0";
echo "\">Click here to continue</a><br /><br />";
} else {
//
echo "<br />Category " . $get_row[Category];
echo " will be deleted.<br /><br />";
echo "<a href=\"delete_category.php?" . session_name() . "=";
echo session_id() . "&RPID=" . $ID;
echo "\">Click here to delete</a><br /><br />";
//delete confirmation
}
}
?></td>
</tr>
</table>
</body>
</html>
|
|