-
Notifications
You must be signed in to change notification settings - Fork 0
/
addnewcity.php
93 lines (85 loc) · 2.74 KB
/
addnewcity.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
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
<?php
include("smartyConfig.php");
include("appWideConfig.php");
include("dbConfig.php");
include("includes/configs/configs.php");
include("function/locality_functions.php");
include("builder_function.php");
include_once("function/locality_functions.php");
AdminAuthentication();
$cityval = $_GET['cityval'];
$id = $_GET['id'];
$deleteCity = $_GET['ciddelete'];
$sel_id = $_GET['id'];
$ins = 0;
$c = 0;
/*******************Delete City******************/
if($deleteCity != '')
{
$qry = "DELETE FROM ".CITY." WHERE CITY_ID = '".$deleteCity."'";
$res = mysql_query($qry);
if($res)
{
$selqry = "SELECT CITY_ID,LABEL FROM ".CITY." ORDER BY LABEL";
$ressel = mysql_query($selqry);
?>
<select name="cityId" id = "cityId" class="cityId" onchange="dispcity(this.value,1);" STYLE="width: 150px">
<option value =''>Select City</option>
<?php
while($data = mysql_fetch_array($ressel))
{
?>
<option value ='<?php echo $data['CITY_ID']; ?>' <?php if( $data['CITY_ID'] == $sel_id ) echo "selected='selected'"; ?>><?php echo $data['LABEL']; ?></option>
<?php
}
?>
</select>
<?php
}
}
else
{
$seldata = "SELECT LABEL FROM ".CITY." WHERE LABEL = '".trim($cityval)."'";
$resdata = mysql_query($seldata);
$ins = mysql_num_rows($resdata);
if( $ins > 0 )
echo 'This city already exist#';
if($cityval!='' && $id!='')
{
$seldata = "UPDATE ".CITY."
SET
LABEL = '".trim($cityval)."',
updated_by = ".$_SESSION['adminId'].",
WHERE CITY_ID='".$id."'";
$resdata = mysql_query($seldata);
$c = mysql_affected_rows();
}
if($c==0 && $ins==0){
$qry = "INSERT INTO ".CITY."
( LABEL, status, updated_by )
value
('".$cityval."','Active',".$_SESSION['adminId'].")";
$res = mysql_query($qry) or die(mysql_error());
$ctid = mysql_insert_id();
$sel_id = $ctid;
$txtCityUrl = createLocalityURL($cityval,'', $ctid, 'city');
$urlUpdate = "update city set url = '$txtCityUrl' where city_id = $ctid";
$urlUp = mysql_query($urlUpdate) or die(mysql_error());
}
$selqry = "SELECT CITY_ID,LABEL FROM ".CITY." ORDER BY LABEL";
$ressel = mysql_query($selqry);
?>
<select name="cityId" id = "cityId" class="cityId" onchange="dispcity(this.value,1);" STYLE="width: 150px">
<option value =''>Select City</option>
<?php
while($data = mysql_fetch_array($ressel))
{
?>
<option value ='<?php echo $data['CITY_ID']; ?>' <?php if( $data['CITY_ID'] == $sel_id ) echo "selected='selected'"; ?>><?php echo $data['LABEL']; ?></option>
<?php
}
?>
</select>
<?php
}
?>