-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_area.php
137 lines (117 loc) · 3.5 KB
/
admin_area.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
session_start();
include("config.php");
include("admin_function.php");
if(!isset($_SESSION['usertype']))
{
header("location:admin.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include("admin_head.php");?>
</head>
<body>
<?php include("admin_topnav.php"); ?>
<div class="container" style='margin-top:70px' >
<div class="row">
<div class="col-sm-3">
<?php include("admin_side_nav.php");?>
</div>
<div class="col-sm-9" >
<h3 class='text-primary'><i class="fa fa-bank"></i> Add Area </h3><hr>
<div class="row">
<div class="col-md-6">
<?php
if(isset($_POST["area_submit"]))
{
$sql="INSERT INTO area(CITY_ID,STATE_ID,AREA_NAME) VALUES ('".$_POST["CITY"]."','".$_POST["statename"]."','".$_POST["areaname"]."')";
$con->query($sql);
}
?>
<p id='out' class='text-success'></p>
<form role="form" action="admin_area.php" method="post">
<div class="form-group text-primary">
<label for="STATE">Select State</label>
<select name="statename" id="STATE" required class="form-control">
<option value="">Select State</option>
<?php
$sql="SELECT STATE_ID,STATE_NAME FROM state ORDER BY STATE_NAME ASC";
$result=$con->query($sql);
if($result->num_rows>0)
{
while($row=$result->fetch_assoc())
{
echo "<option value='{$row['STATE_ID']}'>{$row['STATE_NAME']} </option>";
}
}
?>
</select>
</div>
<div class="form-group">
<span id="city_feed"></span>
</div>
<div class="form-group text-primary">
<label for="area">Area Name</label>
<input id="area" required type="text" class="form-control" name="areaname">
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" name='area_submit' value="Add Area">
</div>
</form>
</div>
<div class="col-md-6">
<?php
$sql="
Select state.STATE_NAME, city.CITY_NAME, area.AREA_NAME, area.AREA_ID
From area Inner Join
state On area.STATE_ID = state.STATE_ID Inner Join
city On area.CITY_ID = city.CITY_ID
ORDER BY AREA_ID desc LIMIT 0,5";
$result=$con->query($sql);
if($result->num_rows>0)
{
echo "<table class='table table-striped' >";
echo "<tr>
<th>Sno</th>
<th>State Name</th>
<th>City Name</th>
<th>Area Name</th>
<th>Delete</th>
</tr>";
$i=0;
while($row=$result->fetch_assoc())
{
$i++;
echo"<tr>";
echo "<td>$i</td>";
echo "<td>".$row["STATE_NAME"]."</td>";
echo "<td>".$row["CITY_NAME"]."</td>";
echo "<td>".$row["AREA_NAME"]."</td>";
echo "<td><a href='admin_del_area.php?id=".$row["AREA_ID"]."' class='btn btn-danger btn-sm'><i class='fa fa-trash'></i></a></td>";
echo"</tr>";
}
echo "</table>";
}
?>
<a href='admin_view_area.php' class='btn btn-primary'><i class='fa fa-edit'></i> View All</a>
</div>
</div>
</div>
</div>
</div>
<?php include("admin_footer.php"); ?>
<script>
$(document).ready(function(){
$("#STATE").change(function(){
var id= $("#STATE").val();
$.post('load_city.php',{sid:id},function(data){
// alert(data);
$("#city_feed").html(data);
});
});
});
</script>
</body>
</html>