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");
$servicesid = $_GET["servicesid"]; $parentid = $_GET["parentid"]; $sort = $_GET["sort"];
//Find ID Category function getAllCategoryID($pid){ $rtnString = ""; $sqlCmd = " SELECT servicesid FROM services WHERE parentid=". $pid ." "; $result = mysql_query($sqlCmd); if (mysql_num_rows( $result)>0 && mysql_num_rows($result) >0) { while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $rtnString .= $row{'servicesid'} .",". getAllCategoryID($row{'servicesid'}); } } return $rtnString; }
//Delete Category $sql = "DELETE FROM services WHERE servicesid in (".substr($servicesid.','.getAllCategoryID($servicesid),0, -1).")"; mysql_query($sql); if( mysql_errno() > 0 ){ echo 'Delete Our Services Error:<br />'. mysql_error() .'<br />SQL: '. $sql; exit; }
// Update Category Sort mysql_query("UPDATE services SET sort = sort-1 WHERE parentid=". $parentid ." AND sort >= ".$sort." ");
mysql_close($dbh);
header("Location: services_index.php?pid=$parentid&msg=Delete Successful"); } ?>
|