/var/www/(Del)yuecreations.com.hk/webadmin/productcol_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
62
63
64
<?php
require("configure.php");

$ProductColourId         $_GET["ProductColourId"];
$Sort                     $_GET["Sort"];


//Delete Child
$sql "SELECT ProductCat.ProductCatId FROM ProductCat WHERE ProductCat.ProductColourId =  "$ProductColourId ." ";
//echo "$sql <br><br>";
$result1 mysql_query($sql) or die(mysql_error());
while (
$row1 mysql_fetch_array($result1,MYSQL_ASSOC))
{

    
$sql "SELECT ProductGrade.ProductGradeId FROM ProductGrade Where ProductCatId="$row1{'ProductCatId'} ." ";
    
//echo "$sql <br><br>";
    
$result2 mysql_query($sql) or die(mysql_error());
    while (
$row2 mysql_fetch_array($result2,MYSQL_ASSOC))
    {
        
// Level 4
        
$sql "DELETE FROM Product WHERE ProductGradeId="$row2{'ProductGradeId'} ." ";
        
//echo "$sql <br><br>";
        
mysql_query($sql);
        if( 
mysql_errno() > ){
            echo 
'Product Detail Delete Error:<br />'mysql_error() .'<br />SQL: '$sql;
            exit;
        }
    }
    
// Level 3
    
$sql "DELETE FROM ProductGrade WHERE ProductCatId="$row1{'ProductCatId'} ." ";
    
//echo "$sql <br><br>";
    
mysql_query($sql);
    if( 
mysql_errno() > ){
        echo 
'Product Grade Delete Error:<br />'mysql_error() .'<br />SQL: '$sql;
        exit;
    }
}
// Level 2
$sql "DELETE FROM ProductCat WHERE ProductColourId="$ProductColourId ." ";
//echo "$sql <br><br>";
mysql_query($sql);
if( 
mysql_errno() > ){
    echo 
'Product Category Delete Error:<br />'mysql_error() .'<br />SQL: '$sql;
    exit;
}


// Delete db
$sql "DELETE FROM ProductColour WHERE ProductColourId="$ProductColourId ." ";
//echo $sql;
mysql_query($sql);
if( 
mysql_errno() > ){
    echo 
'Product Colour Delete Error:<br />'mysql_error() .'<br />SQL: '$sql;
    exit;
}

//echo "UPDATE ProductColour SET Sort = Sort-1 WHERE Sort >= $Sort ";

mysql_query("UPDATE ProductColour SET Sort = Sort-1 WHERE Sort >= $Sort ");
mysql_close($dbh);

header("Location: productcol_index.php?msg=Delete Successful");

?>