This is all my view_content.php you can open it at le-voeu-baliwedding.com/view_content.php if you want to see the problem directly...
$db = mysqli_connect("localhost","levoeuba_admin","levoeu");
if (!$db) {
die("Database connection failed: " . mysqli_error());
}
mysqli_select_db($db,"levoeuba_database_01");
$sql = mysqli_query($db, "SELECT * FROM content ORDER BY id DESC");
$nr = mysqli_num_rows($sql);
if (isset($_GET['pn'])) {
$pn = preg_replace('#[^0-9]#i', '', $_GET['pn']);
$pn = ereg_replace("[^0-9]", "", $_GET['pn']);
} else {
$pn = 1;
}
$itemsPerPage = 2;
$lastPage = ceil($nr / $itemsPerPage);
if ($pn < 1) {
$pn = 1;
} else if ($pn > $lastPage) {
$pn = $lastPage;
}
$centerPages = "";
$sub1 = $pn - 1;
$sub2 = $pn - 2;
$add1 = $pn + 1;
$add2 = $pn + 2;
if ($pn == 1) {
$centerPages .= ' <span class="pagNumActive">' . $pn . '</span> ';
$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> ';
} else if ($pn == $lastPage) {
$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> ';
$centerPages .= ' <span class="pagNumActive">' . $pn . '</span> ';
} else if ($pn > 2 && $pn < ($lastPage - 1)) {
$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub2 . '">' . $sub2 . '</a> ';
$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> ';
$centerPages .= ' <span class="pagNumActive">' . $pn . '</span> ';
$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> ';
$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add2 . '">' . $add2 . '</a> ';
} else if ($pn > 1 && $pn < $lastPage) {
$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '">' . $sub1 . '</a> ';
$centerPages .= ' <span class="pagNumActive">' . $pn . '</span> ';
$centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '">' . $add1 . '</a> ';
}
$limit = 'LIMIT ' .($pn - 1) * $itemsPerPage .',' .$itemsPerPage;
$sql2 = mysqli_query($db, "SELECT * FROM content ORDER BY id DESC $limit");
$paginationDisplay = "";
if ($lastPage != "1"){
$paginationDisplay .= 'Page <strong>' . $pn . '</strong> of ' . $lastPage. ' ';
if ($pn != 1) {
$previous = $pn - 1;
$paginationDisplay .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $previous . '"> Back</a> ';
}
$paginationDisplay .= '<span class="paginationNumbers">' . $centerPages . '</span>';
if ($pn != $lastPage) {
$nextPage = $pn + 1;
$paginationDisplay .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $nextPage . '"> Next</a> ';
}
}
?>
i think the error was in up there? Because the view are running correctly, but not the pagination... the page number is shown as you can see from my web, but the data it input are the same from the first page... anyone can fix this??
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Le Voeu | Bali Wedding</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="css/coin-slider.css" />
<script type="text/javascript" src="js/cufon-yui.js"></script>
<script type="text/javascript" src="js/droid_sans_400-droid_sans_700.font.js"></script>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript" src="js/coin-slider.min.js"></script>
</head>
<body>
<div class="main">
<div class="header">
<div class="header_resize">
<div class="menu_nav">
<ul>
<li class="active"><a href="index.php"><span>Home</span></a></li>
<li class="active"><a href="view_content.php"><span>Content</span></a></li>
<li class="active"><a href="oops.php"><span>Package</span></a></li>
<li class="active"><a href="oops.php"><span>Gallery</span></a></li>
<li class="active"><a href="oops.html"><span>About Us</span></a></li>
</ul>
</div>
<div class="clr"></div>
<div class="logo">
<h1><a href="index.html"><img src="images/DS3.png"/></a></h1>
</div>
<div class="clr"></div>
<div class="clr"></div>
</div>
<div class="clr"></div>
</div>
<div class="clr"></div>
</div>
<div class="header"><center><h2>Content</h2></center></div>
<div class="content">
<div class="content_resize">
<div class="mainbar">
maybe the error was here? I don't really understand php pagination script, because i am still new in this thing. so help?
<?php
$outputList = '';
while($row = mysqli_fetch_array($sql)){
$id = $row["id"];
$title = $row["title"];
$date = $row["date"];
$posted = $row["posted"];
$image = $row["image"];
$content = $row["content"];
?>
<div class="article">
<h2><?php echo $title; ?></h2>
<p class="infopost">Posted In : <?php echo $date; ?></p>
<div class="clr"></div>
<div class="img"><img src="<?php echo $image; ?>" width="620" height="154" alt="" class="fl" /></div>
<div class="post_content">
<p><?php echo $content; ?></p>
<p></p>
<p class="spec"><a href="#" class="rm">Read more...</a></p>
</div>
<div class="clr"><BR></div>
</div>
<?php
}
?>
if it not up there, then it was down here? i just got those one php script down here though....
<p class="pages"><small><?php echo $paginationDisplay; ?></small></p>
</div>
<div class="sidebar">
<div class="searchform">
<form id="formsearch" name="formsearch" method="post" action="#">
<span>
<input name="editbox_search" class="editbox_search" id="editbox_search" maxlength="80" value="Search our site:" type="text" />
</span>
<input name="button_search" src="images/search.gif" class="button_search" type="image" />
</form>
</div>
<div class="clr"></div>
<div class="gadget">
<h2 class="star"><span>Sidebar</span> Menu</h2>
<div class="clr"></div>
<ul class="sb_menu">
<li><a href="index.html">Home</a></li>
<li><a href="gallery.html">Gallery</a></li>
<li><a href="contact.html">Contact Us</a></li>
</ul>
</div>
<div class="gadget">
<h2 class="star"><span>Admin Profile</span></h2>
<div class="userpic">
<img src="#" height="100" width="100" />
<br />
Name : Eric . Prihartono
<br />
Birth Place/Date : Jakarta, 12th April
<br />
</div>
</div>
</div>
<div class="clr"></div>
</div>
</div>
<div class="fbg">
<div class="fbg_resize">
<div class="col c1">
<h2><span>Latest</span> Gallery</h2>
<a href="#"><img src="#" width="75" height="75" alt="" class="gal" /></a> <a href="#"><img src="#" width="75" height="75" alt="" class="gal" /></a> <a href="#"><img src="#" width="75" height="75" alt="" class="gal" /></a> <a href="#"><img src="#" width="75" height="75" alt="" class="gal" /></a> <a href="#"><img src="#" width="75" height="75" alt="" class="gal" /></a> <a href="#"><img src="#" width="75" height="75" alt="" class="gal" /></a> </div>
<div class="col c2">
<h2><span>Services</span> Overview</h2>
<p></p>
<ul class="fbg_ul">
<li><a href="#"></a></li>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
</ul>
</div>
<div class="col c3">
<h2><span>Contact</span> Us</h2>
<p></p>
<p class="contact_info">
<span>Address:</span><br />
<span>Telephone:</span><br />
<span>FAX:</span><br />
<span>Others:</span><br />
<span>E-mail:</span>
</p>
</div>
<div class="clr"></div>
</div>
</div>
<div class="footer">
<div class="footer_resize">
<p class="lf">© Copyright <a href="#">MyWebSite</a>.</p>
<p class="rf">Design by Dream</p>
<div style="clear:both;"></div>
</div>
</div>
</div>
</body>
</html>