Best method to add pagination to a gallery - php

I have clients website that is getting overloaded with images in his gallery. I was wondering if I could get some advice and see what you guys/girls think would be the best way to handle this current situation I'm in.
http://www.richsdockcompany.com/Gallery.php
This gallery is created by php and mysql. I would like to set a limit to 12 images then it would switch to a different page(s), but it can't refresh the page or else the gallery will reset.
Current Code For Gallery
<?php
include_once "header.php";
include($_SERVER['DOCUMENT_ROOT'] . "/connections/dbconnect.php");
$images = mysql_query("SELECT * FROM images");
while ($image=mysql_fetch_assoc($images))
?>
<div id="Wrap">
<div class="Titles"><h2 style="font-size:36px;">Rich's Dock Company Image Gallery</h2></div><br />
<hr />
<div id="PhotoBoxWrap">
<!--======START GALLERY======-->
<div class="row">
<div class="column grid_12">
<div class="row">
<div class="column grid_12">
<!-- start Filter categories -->
<ul id="filter">
<li class="active">All</li>
<li>Dock Builders On Shore</li>
<li>Commercial Docks</li>
<li>Residential Docks</li>
<li>Dock Repairs & Additions</li>
<li>Barge Life</li>
</ul>
<!-- End Filter categories -->
</div>
</div>
<!-- Divider -->
<div class="row">
<div class="column grid_12">
<div class="clear"></div>
<div class="divider spacer5"></div>
</div>
</div>
<!-- End divider -->
<div class="row">
<ul id="stage" class="portfolio-4column">
<?php
$images = mysql_query("SELECT * FROM images ORDER BY id DESC");
while ($image=mysql_fetch_array($images))
{
?>
<li data-id="id-<?=$image["id"] ?>" data-type="<?=$image["data_type"] ?>">
<div class="column grid_3 gallerybox">
<a class="fancybox" rel="<?=$image["data_type"] ?>" href="images/gallery/<?=$image["file_name"] ?>" title="<?=$image["title"] ?>">
<img src="images/gallery/<?=$image["file_name"] ?>" alt="<?=$image["title"] ?>" class="max-img-border"></a>
<h4 style="color:#2B368D; text-align:center;"><?=$image["title"] ?></h4>
<p style="text-align:center; font-size:15px;"><?=$image["description"] ?></p>
</div>
</li>
<?php
}
?>
</ul><!--END LIST-->
The only thing I can think of off the top of my head would be to create a slider that would contain all the images or use ajax with pagination so there would be no refresh problem.
I have never attempted pagination so please go easy on me here.
Any advice would be appreciated.
Thanks!

look at this example code, which handles the pagination in a simple way.
You can reuse the function getPagesNavi for every list which should be paginated.
It returns the html with the links to navigate through the pages.
If you like to load the pages with ajax you need to do some modifications by yourself. This is only an example to show you how it could work.
$page = intval($_GET['page']);
$myurl = 'index.php?action=list';
$db->select("select * from tablename");
$count_total = $db->getRecords();
$items_per_page = 10;
$start = $page * $items_per_page;
$limit = "limit $start, $items_per_page";
$db->select("select * from tablename $limit");
while($row = $db->fetchArray()) {
// your output here...
}
echo getPageNavi($myurl,$page,$count_total,$items_per_page);
function getPagesNavi($link, $current_page, $count_total, $items_per_page, $number_of_visible_pagelinks_updown = 5, $page_varname = "page") {
$result = "";
if ($count_total <= 0) {
return "";
}
$pages_float = $count_total / $items_per_page;
$number_of_pages = ceil($pages_float) - 1;
$start = $current_page - $number_of_visible_pagelinks_updown;
$end = $current_page + $number_of_visible_pagelinks_updown;
if ($end > $number_of_pages) {
$dif = -$number_of_pages + $end;
$end = $number_of_pages;
$start = $start - $dif;
}
if ($start < 0) {
$dif = -$start;
$end = $end + $dif;
$start = 0;
}
if ($end > $number_of_pages) {
$end = $number_of_pages;
}
$back = $current_page - 1;
$forward = $current_page + 1;
if ($current_page > 0) {
$result .= "
<span class=\"pageItem\"><<</span>
<span class=\"pageItem\"><</span>";
} else {
$result .= "<span class=\"pageItem\"><<</span>";
$result .= "<span class=\"pageItem\"><</span>";
}
for ($i = floor($start); $i <= floor($end); $i++) {
$j = $i + 1;
$class = "";
if ($i == $current_page) {
$class = " currentPageItem";
}
$result.= "<span class=\"pageItem$class\">$j</span>";
}
if ($current_page != $number_of_pages) {
$result .= "<span class=\"pageItem\">></span>";
$result .= "<span class=\"pageItem\">>></span>";
} else {
$result .= "<span class=\"pageItem\">></span>";
$result .= "<span class=\"pageItem\">>></span>";
}
return $result;
}

Related

Holding PHP/AJAX filter selections during pagination

I have a page which allows you to filter results using an AJAX call which works fine, I have added pagination which work fine initially but as soon as you move to another page, the checkbox becomes unchecked and it just shows all results again. I assume this is because the page is reloading when it moves to page 2, is there a way of keep the filter setting set and continue to show the results from the filter AJAX. The pagination obvisouly works fine when no filter is selected but my brain just doesn't seem to be working and can't work this out.
Any help would be appreciated!
My code is below, I am also aware that currently my code is open to sql injection but just trying to get everything to work and then will go back through it:
<body>
<?php include("PHP/header.php"); ?>
<div class="container-fluid">
<div class="container" style="margin-top: 2%; text-align: center;">
<h1> Reviews</h1>
On This page you will find our reviews on music tech and software
<br/>
<br/>
<br/>
Filter Reviews:
<ul class="list-group">
<?php
$search = $conn->prepare("SELECT DISTINCT reviewcat FROM review_db ORDER BY reviewcat");
$search->execute();
while ($row = $search->fetch(PDO::FETCH_ASSOC)) {
?>
<li class="list-group-item">
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" class="form-check-input product_check" value="<?=$row['reviewcat'];?>" id="reviewcat"> <?=$row['reviewcat']; ?>
</label>
</div>
</li>
<?php } ?>
</ul>
</div>
<br/><br/>
<div class="row-fluid ">
<h5 class="text-center" id="textChange"> All Reviews </h5>
<hr>
<div class="text-center">
<img src="Images/loader.gif" id="loader" width="100" style="display: none">
</div>
<?php
if (isset($_GET['pageno'])) {
$pageno = $_GET['pageno'];
} else {
$pageno = 1;
}
$no_of_records_per_page = 8;
$offset = ($pageno-1) * $no_of_records_per_page;
// Prev + Next
$prev = $pageno - 1;
$next = $pageno + 1;
?>
<div id="result" class="card-deck card_group_style pt-4" >
<?php
$stmt = $conn->prepare("SELECT COUNT(*) FROM review_db");
$stmt->execute();
$total_rows = $stmt->fetchColumn();
$total_pages = ceil($total_rows / $no_of_records_per_page);
$result = $conn->prepare("SELECT * FROM review_db ORDER BY reviewsub DESC LIMIT $offset, $no_of_records_per_page ");
$result->execute();
?>
<?php while ($row = $result->fetch(PDO::FETCH_ASSOC)) {// Important line !!! Check summary get row on array .. ?>
<?php
$my_date = $row['reviewsub'];
$date = DATE("d/m/Y",strtotime($my_date));
?>
<div class="col-sm-6 col-lg-3 py-2">
<div class="card mb-4">
<img class="card-img-top card-images " src="Images/Reviews/<?php echo $row['reviewimage1'];?>" alt="<?php echo $row['reviewtitle'];?>" >
<div class="card-body">
<h5 class="card-title"><?php echo $row['reviewtitle'];?></h5>
<p class="card-text"><?php echo $row['reviewsynop'];?></p>
<a href="Reviews/review-content.php?id=<?php echo $row['id'];?>&reviewtitle=<?php echo $row['reviewtitle'];?>" class="btn btn-primary my-4" >Read More</a>
<div class="card-footer" style="padding: 1%;">
<small class="text-muted">Submitted: <?php echo $date; ?></small>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
<div class="container">
<!-- Pagination Controller -->
<?php
if($total_pages <= 1){
$hidepage = 'none';
}else{
$hidepage = 'flex';
}
?>
<ul class="pagination justify-content-center pagination-mb" style="display: <?php echo $hidepage; ?>">
<li><a class="page-link" href="?pageno=1">First</a></li>
<li class="page-item <?php if($pageno <= 1){ echo 'disabled'; } ?>">
<a class="page-link" href="<?php if($pageno <= 1){ echo '#'; } else { echo "?pageno=".($pageno - 1); } ?>">Prev</a>
</li>
<?php for($i = 1; $i <= $total_pages; $i++ ): ?>
<li class="page-item <?php if($pageno == $i) {echo 'active'; } ?>">
<a class="page-link" href="?pageno=<?= $i; ?>"> <?= $i; ?> </a>
</li>
<?php endfor; ?>
<li class="page-item <?php if($pageno >= $total_pages){ echo 'disabled'; } ?>">
<a class="page-link" href="<?php if($pageno >= $total_pages){ echo '#'; } else { echo "?pageno=".($pageno + 1); } ?>">Next</a>
</li>
<li><a class="page-link" href="?pageno=<?php echo $total_pages; ?>">Last</a></li>
</ul>
<!-- Pagination end -->
</div>
</div>
</div>
</div>
<?php include("PHP/footer.php"); ?>
</div>
</body>
<?php include("PHP/js.php"); ?>
<script>
$(document).ready(function(){
$('#link-review,#link-footer-review').addClass('active');
});
</script>
<script type="text/javascript">
$(document).ready(function(){
function get_filter_text(text_id){
var filterData = [];
$('#'+text_id+':checked').each(function(){
filterData.push($(this).val());
});
return filterData;
}
$(".product_check").click(function(){
if ($(this).prop('checked')) {
$("#loader").show();
var action = 'data';
var reviewcat = get_filter_text('reviewcat');
$.ajax({
method:'POST',
url:'reviewaction.php',
data:{action:action,reviewcat:reviewcat},
success:function(response){
$("#result").html(response);
$("#loader").hide();
$("#textChange").text("Filtered Reviews");
}
});
} else {
$("#loader").show();
var action = 'data';
var reviewcat = get_filter_text('reviewcat');
$.ajax({
method:'POST',
url:'reviewaction.php',
data:{action:action,reviewcat:reviewcat},
success:function(response){
$("#result").html(response);
$("#loader").hide();
$("#textChange").text("All Reviews");
}
});
}
});
});
</script>
reviewaction.php:
<?php
if(isset($_POST['action'])){
if (isset($_GET['pageno'])) {
$pageno = $_GET['pageno'];
} else {
$pageno = 1;
}
$no_of_records_per_page = 8;
$offset = ($pageno-1) * $no_of_records_per_page;
// Prev + Next
$prev = $pageno - 1;
$next = $pageno + 1;
$checksql = "SELECT COUNT(*) FROM review_db WHERE reviewcat !=''";
$sql = "SELECT * FROM review_db WHERE reviewcat !=''";
if(isset($_POST['reviewcat'])){
$reviewcat = implode("','", $_POST['reviewcat']);
$checksql .="AND reviewcat IN('".$reviewcat."')";
$sql .="AND reviewcat IN('".$reviewcat."')";
}
$resultpag = $conn->prepare($checksql);
$resultpag->execute();
$total_rows = $resultpag->fetchColumn();
$total_pages = ceil($total_rows / $no_of_records_per_page);
$sql .="ORDER BY reviewsub DESC LIMIT $offset, $no_of_records_per_page ";
$result = $conn->prepare($sql);
$result->execute();
$output='';
if (count($result) > 0) {
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$my_date = $row['reviewsub'];
$date = DATE("d/m/Y",strtotime($my_date));
$output .= '
<div class="col-sm-6 col-lg-3 py-2">
<div class="card mb-4">
<img class="card-img-top card-images" src="Images/Reviews/'.$row['reviewimage1'].'" alt="'.$row['reviewtitle'].'" >
<div class="card-body">
<h5 class="card-title">'.$row['reviewtitle'].'</h5>
<p class="card-text">'.$row['reviewsynop'].'</p>
<a href="Reviews/review-content.php?id='.$row['id'].'&reviewtitle='.$row['reviewtitle'].'" class="btn btn-primary my-4" >Read More</a>
<div class="card-footer" style="padding: 1%;">
<small class="text-muted">Submitted: '.$date.'</small>
</div>
</div>
</div>
</div>
';
} //While Loop End
}else{
$output = "<h3>No Reviews Found!</h3>";
}
echo $output;
}
?>
You can do it a couple of ways. One is to add the filter to the GET URI parameters of each page link at the end of your filter function, and add code that marks the filters as selected/checked if the parameters exist in the URI before running the POST request. The other is to change the code so that pagination is done with the same POST request instead of actually navigating to a new URL.

Pagination for search page

I want to make a pagination for search results. I can see the results in first page when I use the search box but I can't see the other results in other pages. What am I doing wrong?
I would be really glad if you could help me
Here' my search page codes.
Codes for pagination
<?php
if(isset($_GET["page"])) {
$page = $_GET["page"];
}else {
$page = "";
}
if($page == "" || $page == 1) {
$starter_post = 0;
} else {
$starter_post = ($page * 6) - 6;
}
$sql_query2 = "SELECT * FROM posts ";
$look_all_post = mysqli_query($conn, $sql_query2);
$all_post_count = mysqli_num_rows($look_all_post);
$page_number = ceil ($all_post_count / 6);
Codes for search results
if(isset($_POST["searchbtn"])) {
$search = $_POST["search"];
$query = "SELECT * FROM posts WHERE post_tags LIKE '%$search%' ORDER BY post_id DESC LIMIT $starter_post, 6";
$search_query = mysqli_query($conn, $query);
if(!$search_query) {
die("QUERY FAILED:". mysqli_error($conn));
}
$search_count = mysqli_num_rows($search_query);
if($search_count == 0) {
echo "<h3> No Result </h3>";
} else {
while ($row = mysqli_fetch_assoc($search_query)){
$post_id = $row["post_id"];
$post_date = $row["post_date"];
$date = strtotime($post_date);
$newdate = date("d/m/Y", $date);
$post_title = $row["post_title"];
$post_text = $row["post_text"];
$post_image = $row["post_image"];
?>
<div class="col-md-6">
<div class="blog">
<div class="blog-img ">
<img src="images/<?php echo $post_image; ?>" class="img-fluid" >
</div>
<div class="blog-content">
<ul class="blog-meta">
<li><i class="far fa-calendar-alt"></i><span class="writer"><?php
echo $newdate; ?></span></li>
</ul>
<h3><?php echo $post_title; ?></h3>
<p><?php echo $post_text; ?></p>
<div class="blog-content2 text-center">
</div>
</div>
</div>
</div>
<?php }
}
}
?>
Codes for pagination
</div>
<div class="row">
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center">
<li <?php if ($page == 1 or $page == "") {echo "class='page-item disabled'";} ?>>
<a class="page-link" href="search.php?page=<?php if ($page > 1) {echo $page - 1;} ?>">Previous</a>
</li>
<?php //Pagination Continue
for($i=1; $i<=$page_number; $i++) {
echo "<li class='page-item'><a class='page-link' href='search.php?page=$i'>{$i}</a></li>";
}
?>
<li <?php if ($page == $page_number) {echo "class='page-item disabled'";} ?>>
<a class="page-link" href="search.php?page=<?php if ($page == "") {echo $page = 2;} else if($page_number!=$page){echo $page+1;} else if($page_number==$page){echo $page;}?>">Next</a>
</li>
</ul>
</nav>
</div>

"Read More" button stopped working in PHP, MySQL CMS

I want to display little amount of text when users come to my blog that's why I've made a "Read More" button to display few texts by cutting off the length of the text and the button was working fine until today when I add a new post via TinyMCE editor I saw that "Read More" button stopped working. While inspecting the error when I disable the function then the "Read More" button comes alive and the link to post is working fine but I'm unable to cut off the length please help me resolve this problem.
I'm using TinyMCE as editor for adding new posts.
This is index.php file.
<?php include("includes/db.php"); ?>
<?php include("includes/header.php"); ?>
<!-- Navigation -->
<?php include("includes/navigation.php"); ?>
<!-- Page Content -->
<div class="container">
<div class="row">
<!-- Blog Entries Column -->
<div class="col-md-8">
<?php
$per_page = 3;
if(isset($_GET['page'])) {
$page = $_GET['page'];
}
else {
$page = "";
}
if($page =="" || $page == 1) {
$page_1 = 0;
}
else {
$page_1 = ($page * $per_page) - $per_page;
}
$post_query_count = "SELECT * FROM posts";
$find_count = mysqli_query($connection, $post_query_count);
$count = mysqli_num_rows($find_count);
$count = ceil($count / $per_page);
$query = "SELECT * FROM posts LIMIT $page_1, $per_page";
$select_all_posts_query = mysqli_query($connection, $query);
while($row = mysqli_fetch_assoc($select_all_posts_query)) {
$post_id = $row['post_id'];
$post_title = $row['post_title'];
$post_user = $row['post_user'];
$post_date = $row['post_date'];
$post_image = $row['post_image'];
$post_content = $row['post_content'];
$post_status = $row['post_status'];
if($post_status == 'published') {
?>
<!-- First Blog Post -->
<h2>
<?php echo $post_title; ?>
</h2>
<p class="lead">
by <?php echo $post_user; ?>
</p>
<p><span class="glyphicon glyphicon-time"></span> <?php echo $post_date; ?></p>
<hr>
<a href="post.php?p_id=<?php echo $post_id; ?>">
<img class="img-responsive" src="images/<?php echo $post_image; ?>" alt="">
</a>
<hr>
<?php echo string_length_cutoff($post_content, 320, '........'); ?>
<a class="btn btn-primary" href="post.php?p_id=<?php echo $post_id; ?>">Read More <span class="glyphicon glyphicon-chevron-right"></span></a>
<hr>
<?php
} }
?>
</div>
<!-- Blog Sidebar Widgets Column -->
<?php include("includes/sidebar.php"); ?>
</div>
<!-- /.row -->
<hr>
<ul class="pager">
<?php
for ($i = 1; $i <= $count; $i++) {
if($i == $page) {
echo "<li><a class='active_link' href='index.php?page={$i}'>{$i}</a></li>";
}
else {
echo "<li><a href='index.php?page={$i}'>{$i}</a></li>";
}
}
?>
</ul>
<?php include("includes/footer.php"); ?>
This function below is stored in functions.php file
function string_length_cutoff($post_content, $limit, $subtext = '...') {
global $connection;
$query = "SELECT * FROM posts";
$select_all_posts_query = mysqli_query($connection, $query);
while($row = mysqli_fetch_assoc($select_all_posts_query)) {
$post_content = $row['post_content'];
}
return (strlen($post_content) > $limit) ? substr($post_content, 0, ($limit-strlen('subtext'))).$subtext : $post_content;
}
Some Screenshots of the actual problem
Read More Button not working
Inspecting read more
read more inspection
I don't think database query is needed. Removed it.
Change your function to:
function string_length_cutoff($post_content, $limit, $subtext = '...') {
$post_content = strip_tags($post_content, '<img>');
return ((strlen($post_content) > $limit) ? substr($post_content, 0, $limit).$subtext : $post_content);
}

Converting old pagination mysql_query php to PDO

I'm trying to switch over to using PDO. I have create a news section on my website.
My database connection is included in my header
I'm currently using this to create the pagination, but need help adding my post
to the $data = array("Hey","Hello","Good-Bye"); As of now Hey, Hello and Good-Bye are the only items working with the pagination.
Can someone hep me get this result: $data = array("add my post here")
Here is my code: My database connection is in the header section.
<?php
class Pagination{
var $data;
function Paginate($values,$per_page){
$total_values = count($values);
if(isset($_GET['page']))
{
$current_page = $_GET['page'];
}
else
{
$current_page = 1;
}
$counts = ceil($total_values / $per_page);
$param1 = ($current_page - 1) * $per_page;
$this->data = array_slice($values,$param1,$per_page);
for ($x=1; $x<= $counts; $x++)
{
$numbers[] = $x;
}
return $numbers;
}
function fetchResult(){
$resultsValues = $this->data;
return $resultsValues;
}
}
?>
I'm assuming that I need the <ul class="notices"> - </ul>(shown below) IN PLACE OF THE $data = array("Hey","Hello","Good-Bye"); DOWN BELOW
Not sure how to do this though?
<ul class="notices">
<?php
$query = $db->query("SELECT id, date, title, description FROM htp_news");
while ($row = $query->fetch(PDO::FETCH_ASSOC))
{
?>
<li data-id="id-<?=$row["id"] ?>">
<article class="box white-bg mb-25">
<div class="notices-title"><?=$row["title"] ?></div>
<div class="newsdate" style="margin: 10px 0 !important;"><?= date("F d, Y", strtotime($row["date"])); ?></div>
<div class="articletext"><style>.articletext img{width:100%; height:auto;}</style><?php $string = $row["description"];
$max = 300; // or 200, or whatever
if(strlen($string) > $max) {
// find the last space < $max:
$shorter = substr($string, 0, $max+1);
$string = substr($string, 0, strrpos($shorter, ' ')).'...';
}
echo $string;
?></div>
<div class="btn small green white-tx">Continue Reading</div>
</article>
</li>
<?php
}
?>
</ul>
<div class="grid_8">
<div class="paginationwrap" align="center">
<!--This is where the pagination numbers are being generated-->
<?php
$pag = new Pagination();
$data = array("Hey","Hello","Good-Bye");//This is where I'm getting confused..?
$numbers = $pag->Paginate($data,1);
$result = $pag->fetchResult();
foreach($result as $r)
{
echo '<div>'.$r.'</div>';
}
foreach($numbers as $num)
{
echo''.$num.'';
}
?>
Any help would be appreciated. Thank you.
Don't know why you need it, but to avoid duplication of code and javascript, you could do this like that, and then you have your data inside $inside_ul variable.
<?php
$query = $db->query("SELECT id, date, title, description FROM htp_news");
$inside_ul = '';
while ($row = $query->fetch(PDO::FETCH_ASSOC))
{
$inside_ul .= '
<li data-id="id-'.$row["id"].'">
<article class="box white-bg mb-25">
<div class="notices-title">'.$row["title"].'</div>
<div class="newsdate" style="margin: 10px 0 !important;">'.date("F d, Y", strtotime($row["date"])).'</div>
<div class="articletext"><style>.articletext img{width:100%; height:auto;}</style>
';
$string = $row["description"];
$max = 300; // or 200, or whatever
if(strlen($string) > $max) {
// find the last space < $max:
$shorter = substr($string, 0, $max+1);
$string = substr($string, 0, strrpos($shorter, ' ')).'...';
}
$inside_ul .= $string.'</div>
<div class="btn small green white-tx">
Continue Reading
</div>
</article>
</li>
';
}
?>
<ul class="notices"><?= $inside_ul; ?></ul>

PHP pagination does not recognize $page

I have downloaded the pagination code and used it for my website running on my local machine. After modifying and testing, there was a problem where it does not recognize the variable $page.
Please refer to the following code:
<?php
$rpp = 3; // results per page
$adjacents = 4;
$page = intval($_GET["page"]);
if($page<=0) $page = 1;
$reload = $_SERVER['PHP_SELF'];
$sql = "SELECT * FROM ".TABLE_IMAGE." ORDER BY id ASC";
$qry = mysql_query($sql, $con);
// count total number of appropriate listings:
$tcount = mysql_num_rows($qry);
// count number of pages:
$tpages = ($tcount) ? ceil($tcount/$rpp) : 1; // total pages, last page number
$i = 1;
$count = 0;
$j = ($page-1)*$rpp;
while(($result = mysql_fetch_array($qry)) && (($count<$rpp) && ($j<$tcount))){
$id = $result['id'];
$img = $result['path'];
$title = $result['title'];
$detail = $result['detail'];
$priority = $result['priority'];
$active = $result['isActive'];
?>
<div id="block-image-slider" class="<?php echo(($i%2==0)?'even':'odd')?>">
<h2><?php echo $title ?></h2><span class="operation">[កែប្រែ|លុប]</span>
<div class="block-slider-image-body">
<div class="left">
<ul>
<li>លេខរៀងទី<span class="space"><?php echo $id ?></span></li>
<li>កំនត់អទិភាពទី<span class="space"><?php echo $priority ?></span></li>
<li>ត្រូវបានបង្ហាញអោយឃើញ<span class="space"><?php echo (($active==1)?'បង្ហាញ':'មិនបង្ហាញ')?></span></li>
<li>អត្ថបទពេញ<div class="detail"><?php echo $detail ?></div></li>
</ul>
</div>
<div class="right">
<img src="<?php echo '../../image/Slider/'.$img ?>" alt="<?php echo $title ?>" width="170" height="100" />
</div>
<div style="clear:both;"></div>
</div>
</div>
<?php
mysql_data_seek($qry,$j);
$i++;
$j++;
$count++;
}//end of while loop
include("../include/paginate.php");
echo paginate_three($reload, $page, $tpages, $adjacents);
?>
This is the error it generated:
Notice: Undefined index: page in C:\wamp\www\1. Chirst Joy Church Website\common\admin\index.php on line 87
How can I fix this error?
This won't work unless your URL ends with ?page=3 (where 3 would be the current page number). In order to fix it you should change this line
$page = intval($_GET["page"]);
to
$page = (!empty($_GET["page"]) ? intval($_GET["page"]) : 1);

Categories