-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
103 lines (100 loc) · 3.38 KB
/
Copy pathindex.php
File metadata and controls
103 lines (100 loc) · 3.38 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
<?php include_once('config.php'); include_once('paginator.class.php'); ?>
<!DOCTYPE html>
<html>
<head>
<title>Pagination with bootstrap</title>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="container">
<hr>
<form method="get" action="<?php echo $_SERVER['PHP_SELF'];?>" class="form-inline">
<select name="tb1" onchange="submit()" class="form-control">
<option>Please select a continent</option>
<?php
$Continentqry = $db->query('SELECT DISTINCT continentName FROM countries ORDER BY continentName ASC');
while($crow = $Continentqry->fetch_assoc()) {
echo "<option";
if(isset($_REQUEST['tb1']) and $_REQUEST['tb1']==$crow['continentName']) echo ' selected="selected"';
echo ">{$crow['continentName']}</option>\n";
}
?>
</select>
</form>
<hr>
<?php
if(isset($_REQUEST['tb1'])) {
$condition = "";
if(isset($_GET['tb1']) and $_GET['tb1']!="")
{
$condition .= " AND continentName='".$_GET['tb1']."'";
}
$qryStr = "SELECT * FROM countries WHERE 1 ".$condition." ORDER BY countryName ASC";
$country = $db->query($qryStr);
$count = $country->num_rows;
$pages = new Paginator($count,9);
echo '<div class="col-sm-6">';
echo '<nav aria-label="Page navigation"><ul class="pagination">';
echo $pages->display_pages();
echo '</ul></nav>';
echo '</div>';
echo '<div class="col-sm-6 text-right">';
echo "<span class=\"form-inline\">".$pages->display_jump_menu().$pages->display_items_per_page()."</span>";
echo '</div>';
echo '<div class="clearfix"></div>';
$limit = $pages->limit_start.','.$pages->limit_end;
$qry = $db->query($qryStr.' LIMIT '.$limit);
}
?>
<table class="table table-bordered table-striped table-hover">
<thead>
<tr class="bg-primary">
<th>Sr#</th>
<th>Country Name</th>
<th>ID</th>
<th>Country Code</th>
<th>Currency Code</th>
<th>Capital</th>
</tr>
</thead>
<tbody>
<?php
if($count>0){
$n = 1;
while($val = $qry->fetch_assoc()){
?>
<tr>
<td><?php echo $n++; ?></td>
<td><?php echo $val['countryName']; ?></td>
<td><?php echo $val['id']; ?></td>
<td><?php echo $val['countryCode']; ?></td>
<td><?php echo $val['currencyCode']; ?></td>
<td><?php echo $val['capital']; ?></td>
</tr>
<?php
}
}else{?>
<tr>
<td colspan="6">No Record(s) Found!</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php
echo '<div class="col-sm-6">';
echo '<nav aria-label="Page navigation"><ul class="pagination">';
echo $pages->display_pages();
echo '</ul></nav>';
echo '</div>';
echo '<div class="col-sm-6 text-right">';
echo "<p class=\"label label-default\">Page: $pages->current_page of $pages->num_pages</p>\n";
echo '</div>';
echo '<div class="clearfix"></div><hr>';
echo "<p class=\"code\">SELECT * FROM table LIMIT $pages->limit_start,$pages->limit_end (retrieve records $pages->limit_start-".($pages->limit_start+$pages->limit_end)." from table - $pages->total_items item total / $pages->items_per_page items per page)";
?>
</div> <!--/.container-->
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
</body>
</html>