/var/www/globavet.com/webadmin/cinfo_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
<?php 
require 'check_login.php';
if (
$logged_in <> 1) {
    
header('Location: login.php');
    return;
}
else
{
require(
"configure.php");

$cinfoid         $_GET["cinfoid"];
$parentid     $_GET["parentid"];
$sort         $_GET["sort"];

//Find ID Category
function getAllCategoryID($pid){                
    
$rtnString "";
    
$sqlCmd " SELECT cinfoid FROM cinfo 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{'cinfoid'} .",".  getAllCategoryID($row{'cinfoid'});                 
                 
       }
    }
    return 
$rtnString;                                     
}

//Delete Category
$sql "DELETE FROM cinfo WHERE cinfoid in (".substr($cinfoid.','.getAllCategoryID($cinfoid),0, -1).")";
mysql_query($sql);
if( 
mysql_errno() > ){
    echo 
'Delete Clients Information Error:<br />'mysql_error() .'<br />SQL: '$sql;
    exit;
}

// Update Category Sort
mysql_query("UPDATE cinfo SET sort = sort-1 WHERE parentid="$parentid ." AND sort >= ".$sort." ");




mysql_close($dbh);

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