Hi, i made this pagination system in the news list, but it's repeating the first data in every pages.
So when i say i want 2 nes per page it's giving me 3 instead, because of it...
if(isset($_GET['page'])){
require('config.php');
$page = $_GET["page"]; //Getting Page number
$pages_query = mysql_query("SELECT COUNT(IdNoticia) FROM noticias"); // Counting total rows
if($page=="" || $page=="0" || $page>$pages_query) { //checking is p is set and greater than 0
$page = 1; //if not set than setting it to 1
}
$per_page = 2; //Total data to display per page
$pages = ceil(mysql_result($pages_query, 0) / $per_page); //dividing total rows with total data to
$start = ($page - 2) * $per_page; // subtracting $p value with 1 and multiplying it with $per_page for example 2-1=1*10 = 10
$QuerySelectAllNews = mysql_query("SELECT * FROM noticias ORDER BY IdNoticia ASC LIMIT $start, $per_page");
$SelectAllNews = mysql_fetch_array($QuerySelectAllNews);
//Running our query
$content='';
do{
$content.='<div id="square_news">';
$content.='<div id="news_banner">';
$content.='<img src="'.$SelectAllNews['ImagemNoticia'].'" />';
$content.='</div>';
$content.='<h2 class="square_news_title">';
$content.='<a href="?idnews='.$SelectAllNews['IdNoticia'].'">'.$SelectAllNews['TituloNoticia'].'</a>';
$content.='<div class="social">';
$content.='<a href="#"><img src="http://bass.house.gov/sites/karenbass.house.gov/files/images/facebook_0.png" width="70px" /></a>';
$content.='</div>';
$content.='<span class="line"></span>';
$content.='</h2>'
$content.='</div>';
echo $content;
}while($SelectAllNews = mysql_fetch_array($QuerySelectAllNews));
for($a=1;$a<=$pages;$a++) { //using for to display number
echo "<a href='?page=$a' class='page_link'>$a</a> "; //printing numbers also using link tags
}
}