-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcity.php
187 lines (169 loc) · 6.57 KB
/
city.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<?php include('header.php'); ?>
<?php
include_once('controller/connect.php');
$dbs = new database();
$db=$dbs->connection();
$name="";
$id="";
//$sql = mysqli_query($db,"select * from city ORDER BY Name");
$staten = mysqli_query($db,"select * from state ORDER BY Name");
if(isset($_GET['cityedit']))
{
$cityid = $_GET['cityedit'];
$edit = mysqli_query($db,"select * from city where CityId='$cityid'");
$row = mysqli_fetch_assoc($edit);
$name = $row['Name'];
$id = $row['StateId'];
}
$page="";
if(isset($_GET['searccity']))
{
$SearchCityName = $_GET['searccity'];
$RecordeLimit = 5;
$searchcity = mysqli_query($db,"select count(CityId) as total from city where Name like '%".$SearchCityName."%'");
$CName = mysqli_fetch_array($searchcity);
$number_of_row =ceil($CName['total']/5);
if(isset($_GET['bn']) &&intval($_GET['bn']) <= $number_of_row && intval($_GET['bn'] !=0))
{
$Skip = (intval($_GET["bn"]) * $RecordeLimit) - $RecordeLimit;
$sql = mysqli_query($db,"select * from city where Name like '%".$SearchCityName."%' LIMIT $Skip,$RecordeLimit ");
}
else
{
$sql = mysqli_query($db,"select * from city where Name like '%".$SearchCityName."%' LIMIT $RecordeLimit ");
}
for($i=0;$i<$number_of_row;$i++)
{
$d = $i+1;
if(isset($_GET["searccity"]))
{
$page .= "<a href='city.php?searccity=$SearchCityName&bn=$d'>$d</a>     ";
}
else
{
$page .= "<a href='city.php?bn=$d'>$d</a>     ";
}
}
}
else
{
$RecordeLimit = 5;
$searchCity = mysqli_query($db,"select count(CityId) as total from city ");
$CName = mysqli_fetch_array($searchCity);
$number_of_row =ceil($CName['total']/5);
if(isset($_GET['bn']) && intval($_GET['bn']) <= $number_of_row && intval($_GET['bn'] != 0 ))
{
$Skip = (intval($_GET["bn"]) * $RecordeLimit) - $RecordeLimit;
$sql = mysqli_query($db,"select * from city LIMIT $Skip,$RecordeLimit");
}
else
{
$sql = mysqli_query($db,"select * from city LIMIT $RecordeLimit");
}
for($i=0;$i<$number_of_row;$i++)
{
$d = $i+1;
$page .= "<a href='city.php?bn=$d'>$d</a>     ";
}
}
?>
<link rel="stylesheet" type="text/css" href="css/table-style.css" />
<link rel="stylesheet" type="text/css" href="css/basictable.css" />
<script type="text/javascript" src="js/jquery.basictable.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#table').basictable();
$('#table-breakpoint').basictable({
breakpoint: 768
});
$('#table-swap-axis').basictable({
swapAxis: true
});
$('#table-force-off').basictable({
forceResponsive: false
});
$('#table-no-resize').basictable({
noResize: true
});
$('#table-two-axis').basictable();
$('#table-max-height').basictable({
tableWrapper: true
});
});
</script>
<ol class="breadcrumb" style="margin: 10px 0px ! important;">
<li class="breadcrumb-item"><a href="Home.php">Home</a><i class="fa fa-angle-right"></i>Table Master<i class="fa fa-angle-right"></i>City</li>
</ol>
<div class="validation-system" style="margin-top: 0;">
<div class="validation-form" style="overflow: auto; margin-right:20px; height: 450px; width: 49%; float: left;">
<!---->
<form method="POST" action="controller/ccity.php?cityedit=<?php echo $row['CityId']; ?>">
<div class="vali-form-group" >
<h2>Add City</h2>
<div class="col-md-3 control-label">
<label class="control-label">State</label>
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-map-marker" aria-hidden="true"></i>
</span>
<select name="state" style="text-transform: capitalize; width: 250px;" required>
<option value="">-- Select State --</option>
<?php while($rw = mysqli_fetch_assoc($staten)){ ?>
<option value="<?php echo $rw["StateId"]; ?>" <?php if($id==$rw["StateId"]){ echo "Selected"; }?>> <?php echo $rw["Name"]; ?> </option>
<?php } ?>
</select>
</div>
</div>
<div class="clearfix"> </div>
<div class="col-md-3 control-label">
<label class="control-label">City</label>
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-map-marker" aria-hidden="true"></i>
</span>
<input type="text" name="city" placeholder="City Name" value="<?php echo $name; ?>" required="" class="form-control" style="width: 250px; height: 35px;">
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="col-md-12 form-group">
<button type="submit" name="cityy" class="btn btn-primary">Add</button>
<button type="reset" class="btn btn-default">Reset</button>
</div>
<div class="clearfix"> </div>
</form>
<!---->
</div>
<div class="validation-form" style="width: 49%; overflow: auto;">
<div style="height: 396px;">
<div class="w3l-table-info" >
<h2>City</h2>
<br>
<form method="GET" action="#">
<input style="float: right;" type="submit" name="searchcity" >
<input style="float: right;" placeholder="Search" type="search-box" name="searccity" value="<?php echo(isset($_GET['searccity']))?$_GET['searccity']:"";?>"><br>
</form>
<table id="table">
<thead>
<tr>
<th>Id</th>
<th style="width: 5000px;">Name</th>
<th style="text-align: center; width: 450px;">Action</th>
</tr>
</thead>
<tbody>
<?php $i=1; while($row = mysqli_fetch_assoc($sql)) { ?>
<tr>
<td><?php if(isset($_GET['bn'])==0){ echo $i; } else{ echo ($_GET['bn']-1)*5+$i; } $i++;?></td>
<td><?php echo ucfirst($row['Name']); ?></td>
<td><a href="?cityedit=<?php echo $row['CityId']; ?>"><i class="fa fa-pencil" aria-hidden="true"></i></a> <a href="controller/ccity.php?citydelete=<?php echo $row['CityId']; ?>"><i class="fa fa-trash-o" aria-hidden="true"></i></a></td>
</tr>
<?php } ?>
</tbody>
</table>
<div><?php echo $page; ?></div>
</div>
</div>
</div>
</div>
<?php include('footer.php'); ?>