-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddnewsubcity.php
More file actions
112 lines (102 loc) · 4.11 KB
/
addnewsubcity.php
File metadata and controls
112 lines (102 loc) · 4.11 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
include_once("smartyConfig.php");
include_once("appWideConfig.php");
include_once("dbConfig.php");
include_once("includes/configs/configs.php");
include_once("builder_function.php");
include_once("function/locality_functions.php");
AdminAuthentication();
require $_SERVER['DOCUMENT_ROOT'].'/dbConfig.php';
$subcityvalnew = $_GET['subcityval'];
$subcityval = str_replace("@","&",$subcityvalnew);
$parent_sub_id = $_GET['parent_id'];
$id = $_GET['id'];
$cityid = $_GET['cityid'];
$sel_id = $_GET['id'];
$ins = 0;
$c = 0;
$deletesubcity = $_GET['deletesubcity'];
$cid = $_GET['cid'];
if($deletesubcity != '')
{
$qry = "DELETE FROM ".SUBURB." WHERE SUBURB_ID = '".$deletesubcity."'";
$res = mysql_query($qry);
if($res)
{
$selqry = "SELECT SUBURB_ID,LABEL FROM ".SUBURB." WHERE CITY_ID = '".$cid."' ORDER BY LABEL";
$ressel = mysql_query($selqry);
?>
<select name="suburbId" id = "suburbId" class="suburbId" onchange="dispcity(this.value,1);" STYLE="width: 150px">
<option value =''>Select Suburb</option>
<?php
while($data = mysql_fetch_array($ressel))
{
?>
<option value ='<?php echo $data['SUBURB_ID']; ?>'><?php echo $data['LABEL']; ?></option>
<?php
}
?>
</select>
<?php
}
}
else
{
require $_SERVER['DOCUMENT_ROOT'].'/dbConfig.php';
$qryCity = "SELECT LABEL FROM ".CITY." WHERE CITY_ID = $cityid";
$resCity = mysql_query($qryCity) or die(mysql_error());
$dataCity = mysql_fetch_assoc($resCity);
$subcityval = trim($subcityval);
$url = "";
$existingSuburb = "select label from suburb where label = '".$subcityval."' and city_id = $cityid";
$existingSuburbRes = mysql_query($existingSuburb);
$existingSuburbData = mysql_num_rows($existingSuburbRes);
if($existingSuburbData > 0)
echo 'This suburb already exist#';
if($subcityval!='' && $id!='')
{
$url = createLocalityURL($subcityval, $dataCity['LABEL'], $id, 'suburb');
$seldata = "UPDATE ".SUBURB."
SET LABEL = '".$subcityval."', URL = '$url',updated_by = '".$_SESSION['adminId']."'
WHERE SUBURB_ID='".$id."'";
$resdata = mysql_query($seldata) or die(mysql_error()." update");
$c = mysql_affected_rows();
}
$seldata = "SELECT LABEL FROM ".SUBURB." WHERE LABEL = '".$subcityval."' AND CITY_ID='".$cityid."'";
$resdata = mysql_query($seldata) or die(mysql_error());
$ins = mysql_num_rows($resdata);
if($c==0 && $ins==0)
{
$qry = "INSERT INTO ".SUBURB." (LABEL,CITY_ID,status,parent_suburb_id, created_at,updated_by)
value('".$subcityval."','".$cityid."','Active','".$parent_sub_id."', NOW(), '".$_SESSION['adminId']."')";
$res = mysql_query($qry) or die(mysql_error()." insert");
$ctid = mysql_insert_id();
$sel_id = $ctid;
$url = createLocalityURL($subcityval, $dataCity['LABEL'], $ctid, 'suburb');
$seldata = "UPDATE ".SUBURB."
SET URL = '$url',updated_by = '".$_SESSION['adminId']."'
WHERE SUBURB_ID='".$ctid."'";
$resdata = mysql_query($seldata);
$c = mysql_affected_rows();
$url = createLocalityURL($subcityval, $dataCity['LABEL'], $ctid, 'suburb');
$seldata = "UPDATE ".SUBURB."
SET URL = '$url',updated_by = '".$_SESSION['adminId']."' WHERE SUBURB_ID='".$ctid."'";
$resdata = mysql_query($seldata);
}
$selqry = "SELECT SUBURB_ID,LABEL FROM ".SUBURB." WHERE CITY_ID='".$cityid."' ORDER BY LABEL";
$ressel = mysql_query($selqry) or die(mysql_error()." select");
?>
<select name="suburbId" id = "suburbId" class="suburbId" onchange="dispsubcity(this.value,1);" STYLE="width: 150px">
<option value =''>Select Suburb</option>
<?php
while($data = mysql_fetch_array($ressel))
{
?>
<option value ='<?php echo $data['SUBURB_ID']; ?>' <?php if( $data['SUBURB_ID'] == $sel_id ) echo "selected='selected'"; ?>><?php echo $data['LABEL']; ?></option>
<?php
}
?>
</select>
<?php
}
?>