PHP USING DYNAMIC PAGINATION
What is pagination?
Pagination is Easy to Navigate one page to another
page and you want navigate specify page to select
<html>
<head></head>
<style>
.para {
letter-spacing: 1px;
font-size: 2.5vw;
line-height: 2.7vw;
font-family: grad,serif;
width: 280px;
}
#home ,
#contact p, footer p {
color: #f9f9f9;
}
.btn {
border:none;
border-radius: 4px;
transition: all 0.4s ease-in-out;
}
.btn:focus {
background: #88b991;
border-color: transparent;
}
.btn-success {
background: #e44c65;
font-weight: 300;
letter-spacing: 2px;
padding: 14px 32px;
margin-top: 26px;
}
.btn-success:hover {
background: #222;
}
a {
color: #fff;
-webkit-transition: 0.5s;
-o-transition: 0.5s;
transition: 0.5s;
text-decoration: none !important;
}
a:hover, a:active, a:focus {
color: #000;
outline: none;
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
*:before,
*:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
/*---------------------------------------
All Section style
-----------------------------------------*/
.oline{
margin-top: 94vh;
font-size:20px;
}
.section-title {
padding-bottom: 62px;
}
#about .section-title {
padding-top: 42px;
}
#about .section-title h1 {
margin-bottom: 0px;
padding-bottom: 0px;
}
#about,
#gallery,
#contact {
padding-top: 0px;
padding-bottom: 120px;
position: relative;
}
#gallery,
#contact, footer {
text-align: center;
}
.overlay {
background: #304352;
opacity: 0.4;
position: absolute;
width: 100%;
height: 0vh;
top: 0;
left: 0;
right: 0;
}
</style>
<style>
.para {
letter-spacing: 1px;
font-size: 2.5vw;
line-height: 2.7vw;
font-family: grad,serif;
width: 280px;
}
#home ,
#contact p, footer p {
color: #f9f9f9;
}
.btn {
border:none;
border-radius: 4px;
transition: all 0.4s ease-in-out;
}
.btn:focus {
background: #88b991;
border-color: transparent;
}
.btn-success {
background: #e44c65;
font-weight: 300;
letter-spacing: 2px;
padding: 14px 32px;
margin-top: 26px;
}
.btn-success:hover {
background: #222;
}
a {
color: #fff;
-webkit-transition: 0.5s;
-o-transition: 0.5s;
transition: 0.5s;
text-decoration: none !important;
}
a:hover, a:active, a:focus {
color: #000;
outline: none;
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
*:before,
*:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
/*---------------------------------------
All Section style
-----------------------------------------*/
.oline{
margin-top: 94vh;
font-size:20px;
}
.section-title {
padding-bottom: 62px;
}
#about .section-title {
padding-top: 42px;
}
#about .section-title h1 {
margin-bottom: 0px;
padding-bottom: 0px;
}
#about,
#gallery,
#contact {
padding-top: 0px;
padding-bottom: 120px;
position: relative;
}
#gallery,
#contact, footer {
text-align: center;
}
.overlay {
background: #304352;
opacity: 0.4;
position: absolute;
width: 100%;
height: 0vh;
top: 0;
left: 0;
right: 0;
}
</style>
<body>
<form id ='fm' method ="post" action ="">
<table>
<tr> <td> name </td> <td> <input type="text" pattern="[a-z]{0,8}" id="name" name="nm"> </td> </tr>
<tr> <td> mark </td> <td> <input type="text" name="mk"></td></tr>
<tr> <td> result </td> <td> <input type="text" name="res"></td></tr>
</table>
<input onclick='chk();' type="submit" name="sub" value="insert">
</form>
</body>
</html>
<?php
$con=mysqli_connect("localhost","root","","test");
if(isset($_POST['sub'])){
$nm=$_POST['nm'];
$mk=$_POST['mk'];
$re=$_POST['res'];
$sql="insert into mark values('$nm','$mk','$re')";
if($con->query($sql)){}
}
error_reporting(0); // Hide the Errors
$page =$_GET['page'];
if($page=='' || $page==0){
$pg =1;
}
else{
$pg =($page*4)-4;
}
echo "
<table border ='2' cellpadding ='6' cellspacing='4'>
<tr> <th> Name </th> <th> Mark </th> <th> Result </th> </tr>
<tr>
";
$sql=" select * from mark LIMIT $pg,4 ";
$res=$con->query($sql);
while($row=mysqli_fetch_assoc($res)){
echo "<td>".$row['name']."</td>";
echo "<td>".$row['mark']."</td>";
echo "<td>".$row['result']."</td>";
echo "</tr>";
}
echo "</table>"."<br>";
$sql=" select * from mark ";
$res=$con->query($sql);
$cnt=mysqli_num_rows($res);
$cont=$cnt/4;
$cont1=ceil($cont);
for($i=1;$i<=$cont1;$i++){
?>
<li type="none" style="float:left;border:1px solid gray;padding-left:1%">
<a style="text-decoration:none;" href='paginate.php?page=<?php echo $i;?>'><?php echo $i; ?></a></li>
<?php
}
?>
Output :
Before Insert Record
No comments:
Post a Comment