-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_view_state.php
143 lines (117 loc) · 2.95 KB
/
admin_view_state.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
<?php
session_start();
include("config.php");
include("admin_function.php");
if(!isset($_SESSION['usertype']))
{
header("location:admin.php");
}
$sql="SELECT * FROM state";
$result=$con->query($sql);
$rows=$result->num_rows;
$page_rows=5;
$last=ceil($rows/$page_rows);
if($last<1)
{
$last=1;
}
$pagenum=1;
if(isset($_GET['pn']))
{
$pagenum=preg_replace('#[^0-9]#','',$_GET['pn']);
}
if($pagenum<1){
$pagenum=1;
}
elseif($pagenum>$last)
{
$pagenum=$last;
}
$limit='LIMIT '.($pagenum-1)*$page_rows.','.$page_rows;
$sql="Select country.COUNTRY_NAME, state.STATE_NAME,state.STATE_ID
From state Inner Join
country On state.COUNTRY_ID = country.COUNTRY_ID ORDER BY STATE_ID desc $limit ";
$textline1="Total State : $rows";
$textline2="Page <b>$pagenum</b> Of <b>$last</b>";
$paginationctrls='<ul class="pagination">';
if($last!=1)
{
if($pagenum>1)
{
$previous=$pagenum-1;
$paginationctrls.=' <li><a href="'.$_SERVER['PHP_SELF'].'?pn='.$previous.'">Previous</a></li>';
for($i=$pagenum-4;$i<$pagenum;$i++)
{
if($i>0)
{
$paginationctrls.='<li><a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'">'.$i.'</a></li>';
}
}
}
$paginationctrls.='<li class="active" ><a href="#" >'.$pagenum.'</a></li> ';
for($i=$pagenum+1;$i<=$last;$i++)
{
$paginationctrls.='<li><a href="'.$_SERVER['PHP_SELF'].'?pn='.$i.'">'.$i.'</a> </li>';
if($i>=$pagenum+4)
{
break;
}
}
if($pagenum!=$last)
{
$next=$pagenum+1;
$paginationctrls.='<li><a href="'.$_SERVER['PHP_SELF'].'?pn='.$next.'">Next</a></li></ul>';
}
}
$list='';
$result=$con->query($sql);
if($result->num_rows>0)
{
$list.= "<table class='table table-striped' >";
$list.= "<tr>
<th>Sno</th>
<th>Country Name</th>
<th>State Name</th>
<th>Delete</th>
</tr>";
$i=0;
while($row=$result->fetch_assoc())
{
$i++;
$list.="<tr>";
$list.= "<td>$i</td>";
$list.= "<td>".$row["COUNTRY_NAME"]."</td>";
$list.= "<td>".$row["STATE_NAME"]."</td>";
$list.= "<td><a href='admin_del_state.php?id=".$row["STATE_ID"]."' class='btn btn-danger btn-sm'><i class='fa fa-trash'></i></a></td>";
$list.="</tr>";
}
$list.= "</table>";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include("admin_head.php");?>
</head>
<body>
<?php include("admin_topnav.php"); ?>
<div class="container">
<div class="row">
<div class="col-sm-3">
<?php include("admin_side_nav.php");?>
</div>
<div class="col-sm-9" >
<h3><i class="fa fa-bank"></i> View State Details </h3><hr>
<div class="col-md-12">
<p><?php echo $textline1; ?></p>
<p><?php echo $textline2; ?></p>
<?php echo $list; ?>
<?php echo $paginationctrls; ?>
</div>
</div>
</div>
</div>
</div>
<?php include("admin_footer.php"); ?>
</body>
</html>