I wanted to display maximum 12 image in a page and if more is there there will show pages number like page 1, page 2… I have tried with this code but all images showing in page1 and page2 also showing the same images. How I can limit and show first 12 image in page 1 and next 12 in page 2?
Please help with the code I have tried.
[php]
<?php require_once 'dbconfig.php'; if(isset($_GET['delete_id'])) { // select image from db to delete $stmt_select = $DB_con->prepare('SELECT userPic FROM tbl_users WHERE userID =:uid'); $stmt_select->execute(array(':uid'=>$_GET['delete_id'])); $imgRow=$stmt_select->fetch(PDO::FETCH_ASSOC); unlink("user_images/".$imgRow['userPic']); // it will delete an actual record from db $stmt_delete = $DB_con->prepare('DELETE FROM tbl_users WHERE userID =:uid'); $stmt_delete->bindParam(':uid',$_GET['delete_id']); $stmt_delete->execute(); header("Location: index3.php"); } ?> new$stmt = $DB_con->prepare('SELECT userID, userName, userProfession, userPic FROM tbl_users ORDER BY userID DESC');
$stmt->execute();
if($stmt->rowCount() > 0)
{
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
extract($row);
?>
<div class="col-xs-3">
<!-- imgage info uper header sumon <p class="page-header">//<?php echo $userName." / ".$userProfession; ?></p> -->
<img src="user_images/<?php echo $row['userPic']; ?>" class="img-rounded" width="250px" height="250px" />
<p class="page-header" align="left">
<?php echo $userName." / ".$userProfession; ?> <br/>
</p>
</div>
<?php
}
}
else
{
?>
<div class="col-xs-12">
<div class="alert alert-warning">
<span class="glyphicon glyphicon-info-sign"></span> No Data Found ...
</div>
</div>
<?php
}
?>
<?php
$con = mysqli_connect(“localhost”,“root”,"");
if (!$con)
{
die();
}
mysqli_select_db($con,“shopiteam”);
if (isset($_GET[“page”])) { $page = $_GET[“page”]; } else { $page=1; };
$start_from = ($page-1) * 12;
$sql = “SELECT * FROM tbl_users where status=‘process’ ORDER BY albumid DESC LIMIT $start_from, 12”;
//$rs_result = mysql_query ($sql,$con);
$rs_result= mysqli_query($con,$sql);
$sql = “SELECT COUNT(userName) FROM tbl_users”;
$rs_result = mysqli_query($con,$sql);
$row = mysqli_fetch_row($rs_result);
$total_records = $row[0];
$total_pages = ceil($total_records / 12);
for ($i=1; $i<=$total_pages; $i++) {
echo “”;
echo “Page “;
echo “”.$i.””;
echo “”;
};
?>
</div>
</div>
</div>