
Hola amigos de Foros del Web, encontre un tutorial de una galeria dinamica en php, la cual funciona a las mil maravillas (muy bonita por cierto) este es el link "http://tutorialzine.com/2009/09/cool-jquery-gallery/", y queria utilizarla en mi proyecto de pagina, entre los comentarios que dejan los lectores de la pagina explican como hacer que esta galeria posea una
paginacion, pues bien segui paso a paso el tutorial y lo consegui, pero surge un
problemita, que no he podido resolver, el cual es que la galeria me repite imagenes al pasar de pagina; de un total de 24 imagenes en la galeria, cada pagina enseña de a 8 imagenes, deberian haber solo 3 paginas pero muestra 4; aca dejo el link "http://www.saguicreativos.com/Archivos/demo.php" para que observen lo que sucede.
Intente buscar ayuda dentro de la misma pagina del tutorial hace mas de un mes, (no hay cuña que mas aprete que la del mismo palo) pero no he obtenido respuesta alguna, por eso acudo a su increible sapiencia ya que en esto de php soy nuevo y este es mi primer intento de hacer algo con php (o por lo menos entender algo

)
De antemano muchas gracias a quien me pueda ayudar, y aca dejo el code:
Código:
<div id="container">
<div id="heading">
<h1>Galería de Imágenes</h1>
</div>
<div id="gallery">
<?php
$directory = '../Prueba/images'; //Carpeta de imagenes
$miniaturas = '../Prueba/images/minis'; //Carpeta de miniaturas
$allowed_types=array('jpg','jpeg','gif','png');
$file_parts=array();
$ext='';
$title='';
$i=0;
$dir_handle = @opendir($directory) or die("Hay un error con su directorio de imagenes!");
/**********************************/
/*PAGINACION*/
$page = 1;
if ( (int)$_GET['page'] > 1 ) $page = (int)$_GET['page'];
$imgPerPage = 8; // imagenes en pantalla
$start = ($page-1)*$imgPerPage;
$stop = $start + $imgPerPage;
/**********************************/
while ($file = readdir($dir_handle)) {
/**********************************/
if($i< $start || $i>=$stop) { $i++; continue; }
/**********************************/
if($file == '.' || $file == '..') continue;
$file_parts = explode('.',$file);
$ext = strtolower(array_pop($file_parts));
$title = implode('.',$file_parts);
$title = htmlspecialchars($title);
$nomargin='';
if(in_array($ext,$allowed_types))
{
if(($i+1)%4==0) $nomargin='nomargin';
echo '<div class="pic '.$nomargin.'" style="background:url('.$miniaturas.'/'.$file.') no-repeat;">
<a href="'.$directory.'/'.$file.'" title="'.$title.'" target="_blank">'.$title.'</a></div>';
$i++;
}
}
closedir($dir_handle);
/*********************************/
echo getPaginationString($page,$i,$imgPerPage,1,'galeriaMiniaturas.php');
/**********************************/
/**********************************/
// Función para poner el link de paginación
function getPaginationString($page = 1, $totalitems, $limit = 10, $adjacents = 1, $targetpage = "/", $pagestring = "?page=")
{
//defaults
if(!$adjacents) $adjacents = 1;
if(!$limit) $limit = 10;
if(!$page) $page = 1;
if(!$targetpage) $targetpage = "/";
//otras variables
$prev = $page - 1; //previous page is page - 1
$next = $page + 1; //next page is page + 1
$lastpage = ceil($totalitems / $limit); //lastpage is = total items / items per page, rounded up.
$lpm1 = $lastpage - 1; //last page minus 1
//Now we apply our rules and draw the pagination object.
//We're actually saving the code to a variable in case we want to draw it more than once.
$pagination = "";
if($lastpage > 1)
{
$pagination .= "<div class=\"pagination\"";
if($margin || $padding)
{
$pagination .= " style=\"";
if($margin)
$pagination .= "margin: $margin;";
if($padding)
$pagination .= "padding: $padding;";
$pagination .= "\"";
}
$pagination .= ">";
//boton anterior
if ($page > 1)
$pagination .= "<a href=\"$targetpage$pagestring$prev\">« ant</a>";
else
$pagination .= "<span class=\"disabled\">« ant</span>";
//pages
if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination .= "<span class=\"current\">$counter</span>";
else
$pagination .= "<a href=\"" . $targetpage . $pagestring . $counter . "\">$counter</a>";
}
}
elseif($lastpage >= 7 + ($adjacents * 2)) //enough pages to hide some
{
//close to beginning; only hide later pages
if($page < 1 + ($adjacents * 4))
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
$pagination .= "<span class=\"current\">$counter</span>";
else
$pagination .= "<a href=\"" . $targetpage . $pagestring . $counter . "\">$counter</a>";
}
$pagination .= "<span class=\"elipses\">...</span>";
$pagination .= "<a href=\"" . $targetpage . $pagestring . $lpm1 . "\">$lpm1</a>";
$pagination .= "<a href=\"" . $targetpage . $pagestring . $lastpage . "\">$lastpage</a>";
}
//in middle; hide some front and some back
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
$pagination .= "<a href=\"" . $targetpage . $pagestring . "1\">1</a>";
$pagination .= "<a href=\"" . $targetpage . $pagestring . "2\">2</a>";
$pagination .= "<span class=\"elipses\">...</span>";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
$pagination .= "<span class=\"current\">$counter</span>";
else
$pagination .= "<a href=\"" . $targetpage . $pagestring . $counter . "\">$counter</a>";
}
$pagination .= "...";
$pagination .= "<a href=\"" . $targetpage . $pagestring . $lpm1 . "\">$lpm1</a>";
$pagination .= "<a href=\"" . $targetpage . $pagestring . $lastpage . "\">$lastpage</a>";
}
//close to end; only hide early pages
else
{
$pagination .= "<a href=\"" . $targetpage . $pagestring . "1\">1</a>";
$pagination .= "<a href=\"" . $targetpage . $pagestring . "2\">2</a>";
$pagination .= "<span class=\"elipses\">...</span>";
for ($counter = $lastpage - (1 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination .= "<span class=\"current\">$counter</span>";
else
$pagination .= "<a href=\"" . $targetpage . $pagestring . $counter . "\">$counter</a>";
}
}
}
//next button
if ($page < $counter - 1)
$pagination .= "<a href=\"" . $targetpage . $pagestring . $next . "\">sig »</a>";
else
$pagination .= "<span class=\"disabled\">sig »</span>";
$pagination .= "</div>\n";
}
return $pagination;
}
/**********************************/
?>
<div class="clear"></div>
</div>
<div id="footer">
<h2>Esto es una <a href="#" target="_blank">Galería </a>de ejemplo.</h2>
</div>
[/HIGHLIGHT]