/var/www/c-c.com.hk/webadmin/project_category_delete.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
include 'config.php';

// Check if the user is logged in

if ((!isSet($_SESSION['loginname'])) || ($loggin <> '1'))
{
header("Location: login.php");
exit;
}
require(
"configure.php");

$pjcatid     $_GET["pjcatid"];
$parentid     $_GET["parentid"];
$pjcatsort     $_GET["pjcatsort"];

//Delete Category
function getAllCategoryID($pid){                
    
$rtnString "";
    
$sqlCmd " SELECT pjcatid FROM project_cat WHERE parentid="$pid ." ";
    
$result mysql_query($sqlCmd);
    if (
mysql_num_rows$result)>&& mysql_num_rows($result) >0)
    {                   
       while(
$row mysql_fetch_array($resultMYSQL_ASSOC))
       {
                 
$rtnString .= $row{'pjcatid'} .",".  getAllCategoryID($row{'pjcatid'});                 
                 
       }
    }
    return 
$rtnString;                                     
}


// Delete Product Detail
/*$sql2 = "DELETE FROM inv_product_category ";
$sql2 .= "where catid in (".substr($catid.','.getAllCategoryID($catid),0, -1).")";
//echo 'Product Detail prodcatid = '.$sql2.'<br />';
mysql_query($sql2);
if( mysql_errno() > 0 ){
    echo 'Delete Product Detail Category Error:<br />'. mysql_error() .'<br />SQL: '. $sql2;
    exit;
}*/


//Delete Category
$sql1 "DELETE FROM project_cat ";
$sql1 .= "where pjcatid in (".substr($pjcatid.','.getAllCategoryID($pjcatid),0, -1).")";
//echo 'Category prodcatid = '.$sql1.'<br />';
mysql_query($sql1);
if( 
mysql_errno() > ){
    echo 
'Delete Product Category Error:<br />'mysql_error() .'<br />SQL: '$sql1;
    exit;
}
// Update Category Sort
mysql_query("UPDATE project_cat SET pjcatsort = pjcatsort-1 WHERE parentid="$parentid ." AND pjcatsort >= $pjcatsort ");

mysql_close($dbh);

header("Location: project_category_index.php?pid=$parentid&msg=Delete Successful");

?>