arkadaşlar ücretsiz foto galeri scriptindeki resim görüntüleme sayfasında bulunan ileri geri butonları 4-5 resimden sonra kayma yapıyor rica etsem yardımcı olurmusunuz..

<?php define("include",true); include("config.php"); include("plugin/functions.php");
mysql_query("SET NAMES 'utf8'"); $url = $_GET['url'];
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET COLLATION_CONNECTION = 'utf8_bin'");
$query = mysql_query("select * from ayarlar");
while($print = mysql_fetch_array($query)){ $ccc = mysql_query("select * from galeriler where seflink='$url'"); if(mysql_num_rows($ccc)=="0"){ header("Location:404.php"); }else{ while($ddd = mysql_fetch_array($ccc)){ ?>
<!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>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<meta name="description" content="<?php echo $ddd['description']; ?>" />
	<meta name="keywords" content="<?php echo $ddd['keywords']; ?>" />	
	<meta name="author" content="Php Scriptlerim, www.phpscriptlerim.com" />	

	<title><?php echo $ddd['baslik']; ?> | <?php echo $print['title']; ?></title>
	<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<div id="wrapper">
  <div id="header">
    <ol>
      <li class="f"><a href="index<?php echo $print['seourl']; ?>">Anasayfa</a></li>
      <li><a href="iletisim<?php echo $print['seourl']; ?>">İletişim</a></li>
    </ol>
	
    <p class="links"><?php echo fuctarih(); ?></p>
	
    <h1><a href="index<?php echo $print['seourl']; ?>"><?php echo $print['title']; ?></a></h1>

    <div class="ad"><?php echo $print['reklam468']; ?></div>

    <ul>
<?php $aaa = mysql_query("select * from galerikat order by sira asc"); while($bbb = mysql_fetch_array($aaa)){ if($print['seourl']==".php"){ ?>	
      <li><a href="gkat.php?url=<?php echo $bbb['seflink']; ?>"><?php echo $bbb['baslik']; ?></a></li>
	<?php }elseif($print['seourl']==".html"){ ?>
      <li><a href="kategori-<?php echo $bbb['seflink']; ?>.html"><?php echo $bbb['baslik']; ?></a></li>	
<?php } } ?>
    </ul>
  </div>
<?php $limit = 1; $page = @$_GET["page"];

if(empty($page) or !is_numeric($page)) { $page = 1; }

	$count			 = mysql_num_rows(mysql_query("SELECT id FROM resimler where rID='".$ddd['id']."' order by id desc"));
	$toplamsayfa	 = ceil($count / $limit);
	$baslangic		 = ($page-1)*$limit;

if($toplamsayfa < @$_GET["page"]){ echo '<meta http-equiv="refresh" content="0;URL=http://www.google.com">'; exit(); }else{ }	
	
$sorustur = "SELECT * FROM resimler where rID='".$ddd['id']."' ORDER BY id desc LIMIT $baslangic,$limit";

$yazdir_sorgu = mysql_query($sorustur) or die(mysql_error()); if(mysql_num_rows($yazdir_sorgu)=="0"){ echo '<b style="color:blue;">Eklenmiş bir resim bulunamadı.</b>'; }else{

while ($yazdir = mysql_fetch_array($yazdir_sorgu)){ ?> 
  <div id="content">
    <div class="post">
      <h2><?php echo $ddd['baslik']; ?></h2>
	<img src="<?php echo $yazdir['resimyolu']; ?>" alt="<?php echo $ddd['baslik']; ?>"><br><br>
	
	Şuan <b><?php echo $page; ?>.</b> resimdesiniz. Toplam <b><?php echo $toplamsayfa; ?></b> resim vardır.
      <div class="break"></div>
    </div>
  </div>
  
  <div id="sidebar" style="margin-bottom:100px;">
    <div class="box">
	<?php echo $yazdir['text']; ?>
    </div>
  </div>
<?php } } echo '<div class="pagination">';
if($count > $limit) : 
  $x = 2; 
  $lastP = ceil($count/$limit); 

if($print['seourl']==".php"){  
  if($page > 1){
  $onceki = $page-1;
  echo "<a href=\"?url=$url&page=$onceki\">« Geri</a>"; 
  }
 
  if($page==1) echo "<span class='active'>1</span>"; 
  else echo "<a href='?url=$url&page=1'>1</a>";   
  
  if($page-$x > 2) { 
    echo "<span>...</span>"; 
    $i = $page-$x; 
  } else { 
    $i = 2; 
  } 

  for($i; $i<=$page+$x; $i++) { 
    if($i==$page) echo "<span class=\"active\">$i</span>"; 
    else echo "<a href=\"?url=$url&page=$i\">$i</a>"; 
    if($i==$lastP) break; 
  }

  if($page+$x < $lastP-1) { 
    echo "<span>...</span>"; 
    echo "<a href=\"?url=$url&page=$lastP\">$lastP</a>"; 
  } elseif($page+$x == $lastP-1) { 
    echo "<a href=\"?url=$url&page=$lastP\">$lastP</a>"; 
  } 

  if($page < $lastP){
  $sonraki = $page+1;
  echo "<a href=\"?url=$url&page=$sonraki\">İleri »</a>"; 
  } }elseif($print['seourl']==".html"){  
  if($page > 1){
  $onceki = $page-1;
  echo "<a href=\"galeri-$url&page=$onceki.html\">« Geri</a>"; 
  }
 
  if($page==1) echo "<span class='active'>1</span>"; 
  else echo "<a href='galeri-$url&page=1.html'>1</a>";   
  
  if($page-$x > 2) { 
    echo "<span>...</span>"; 
    $i = $page-$x; 
  } else { 
    $i = 2; 
  } 

  for($i; $i<=$page+$x; $i++) { 
    if($i==$page) echo "<span class=\"active\">$i</span>"; 
    else echo "<a href=\"galeri-$url&page=$i.html\">$i</a>"; 
    if($i==$lastP) break; 
  }

  if($page+$x < $lastP-1) { 
    echo "<span>...</span>"; 
    echo "<a href=\"galeri-$url&page=$lastP.html\">$lastP</a>"; 
  } elseif($page+$x == $lastP-1) { 
    echo "<a href=\"galeri-$url&page=$lastP.html\">$lastP</a>"; 
  } 

  if($page < $lastP){
  $sonraki = $page+1;
  echo "<a href=\"galeri-$url&page=$sonraki.html\">İleri »</a>"; 
  } }  
  endif; ?>  
	</div>
	
  <div id="footer">
    <p class="l">Copyright &copy; <?php echo date('Y'); ?>, <?php echo $print['title']; ?>. Tüm hakları saklıdır.</p>
    <p class="r">Powered by : <a href="http://www.phpscriptlerim.com" target="_blank">Php Scriptlerim</a></p>
  </div>
</div>

</body>
</html>
<?php } } } ?>