Simple pagination Script Kaise Bnaye-Php & Mysql
Aap demo niche diye gye link se check kar sakte ho.
Demo-Simple Pagination with Php & mysql
Step1-database connection ke liye ek db.php name se file create kar lijiye
db.php
<?php
$conn=mysqli_connect("localhost","root","","malala");//enter your databse name here
?>
Step2-ab index.php name se file create kar lijiye
index.php
<center>
<?php
include 'db.php';
$limit = 2;
if (isset($_GET["page"]))
{
$page = $_GET["page"];
} else {
$page=1;
};
$start_from = ($page-1) * $limit;
$sql = "SELECT * FROM demo ORDER BY id ASC LIMIT $start_from, $limit";
$rs_result = mysqli_query($conn, $sql);
?><?php
while ($row = mysqli_fetch_assoc($rs_result)) {
$id=$row['id'];
$title=$row['title'];
$name=$row['name'];
$content=substr($row['content'],0,10);
$image=$row['post_image'];
$singer=substr($row['singer'],0,5);
$photo=$row['photo'];
?>
<img src="uploads/<?php echo $photo; ?>" width="100" height="100"/>
<h1> <?php echo $row["title"]; ?> </h1>
<font color="red"> <h3> Author: <?php echo $row["name"]; ?> </h3></font>
<?php echo "<br>" ?>
<?php echo $row["content"]; ?>
<p align ="right"><button><a href="page.php?id=<?php echo $id; ?>">READ
MORE</a></button></p>
<?php
};
?>
<?php
include 'pagination.php';
?>
Step3 pagination.php name se ek file create kar lijiye
pagination.php
<?php
$Gajabwap = "";
$sql = "SELECT COUNT(id) FROM demo";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_row($result);
for ($i=1; $i<=ceil($row[0] / $limit); $i++) {
$Gajabwap .= "<button><a href='index.php?page=".$i."'>".$i."</a></button>";
};
echo $Gajabwap;
?>
is parkar aap easily apne liye pagination teyar kar sakte ho.
Download Link for Full Pagination code –
Download Pagination Script
Thank You
Team Gajabwap Web In Hindi
1 comments:
Click here for commentsnice script bro It is working very well You save My time thanks bro for this code
ConversionConversion EmoticonEmoticon