-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
148 lines (132 loc) · 4.87 KB
/
index.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
<?php
include_once('config.php');
include('vendor/autoload.php');
?>
<!doctype html>
<html lang="en-US" xmlns:fb="https://www.facebook.com/2008/fbml" xmlns:addthis="https://www.addthis.com/help/api-spec" prefix="og: http://ogp.me/ns#" class="no-js">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>PHP pagination class with Bootstrap 4</title>
<link rel="shortcut icon" href="https://demo.learncodeweb.com/favicon.ico">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-6724419004010752",
enable_page_level_ads: true
});
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-131906273-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'UA-131906273-1');
</script>
</head>
<body>
<div class="container">
<h1><a href="https://learncodeweb.com/php/php-pagination-class-with-bootstrap-4/">PHP pagination class with Bootstrap 4</a></h1>
<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'] . "'";
}
//Main query
$pages = new Paginator;
$pages->default_ipp = 15;
$sql_forms = $db->query("SELECT * FROM countries WHERE 1 " . $condition . "");
$pages->items_total = $sql_forms->num_rows;
$pages->mid_range = 9;
$pages->paginate();
$result = $db->query("SELECT * FROM countries WHERE 1 " . $condition . " ORDER BY countryName ASC " . $pages->limit . "");
}
?>
<div class="clearfix"></div>
<div class="row marginTop">
<div class="col-sm-12 paddingLeft pagerfwt">
<?php if ($pages->items_total > 0) { ?>
<?php echo $pages->display_pages(); ?>
<?php echo $pages->display_items_per_page(); ?>
<?php echo $pages->display_jump_menu(); ?>
<?php } ?>
</div>
<div class="clearfix"></div>
</div>
<div class="clearfix"></div>
<table class="table table-bordered table-striped">
<thead>
<tr>
<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 ($pages->items_total > 0) {
$n = 1;
while ($val = $result->fetch_assoc()) {
?>
<tr>
<td><?php echo $n++; ?></td>
<td><?php echo mb_strtoupper($val['countryName']); ?></td>
<td><?php echo $val['id']; ?></td>
<td><?php echo mb_strtoupper($val['countryCode']); ?></td>
<td><?php echo mb_strtoupper($val['currencyCode']); ?></td>
<td><?php echo mb_strtoupper($val['capital']); ?></td>
</tr>
<?php
}
} else { ?>
<tr>
<td colspan="6" align="center"><strong>No Record(s) Found!</strong></td>
</tr>
<?php } ?>
</tbody>
</table>
<div class="clearfix"></div>
<div class="row marginTop">
<div class="col-sm-12 paddingLeft pagerfwt">
<?php if ($pages->items_total > 0) { ?>
<?php echo $pages->display_pages(); ?>
<?php echo $pages->display_items_per_page(); ?>
<?php echo $pages->display_jump_menu(); ?>
<?php } ?>
</div>
<div class="clearfix"></div>
</div>
<div class="clearfix"></div>
</div>
<!--/.container-->
</body>
</html>