Ver Mensaje Individual
  #22 (permalink)  
Antiguo 04/06/2009, 07:20
Ash_AM
 
Fecha de Ingreso: abril-2009
Ubicación: Cuba
Mensajes: 54
Antigüedad: 15 años
Puntos: 2
Respuesta: Como muestro imagen siguiente y anterior en galeria de imagenes?

Hola, tienes un error, entre otras cosas...

Cuando haces la comparación de anterior, el signo de diferente es != (no !==).

Aquí te pongo un código, espero que te resulte.
Dime si te da algún error.

Saludos.

Código PHP:
<?php  
session_start
();  

// incluimos el archivo de conexion  
include ('../../usuarios/reg/config.php');  

$id_pastora=$_GET['id_pastora'];
 
//Obtener anterior imagen 
$estructura "SELECT id_pastora, imagen_pastora FROM galeriapastora WHERE id_pastora <= '$id_pastora' ORDER BY  id_pastora DESC LIMIT 1";    
$sqlQueryNot mysql_query($estructura$db_link) or die(mysql_error());  
$rowNot mysql_fetch_array($sqlQueryNot);  

//Obtener actual y siguiente 
$estructura2 "SELECT id_pastora, imagen_pastora FROM galeriapastora WHERE id_pastora >= '$id_pastora' ORDER BY  id_pastora ASC LIMIT 2";  
$sqlQueryNot2 mysql_query($estructura2$db_link) or die(mysql_error());  

//cantidad de record encontrados = 1 no hay siguiente; =2 hay siguiente
$siguiente mysql_num_rows($sqlQueryNot2);

//Aquí me quedo con la imagen actual y paso al siguiente record. Eso lo hace mysql_fetch_array.
$rowNot2 mysql_fetch_array($sqlQueryNot2);

$anterior = (mysql_num_rows($sqlQueryNot) > 0) ? mysql_fetch_array($sqlQueryNot) : false;

echo 
"<div id=\"verfoto\"><img src=\"".$rowNot2['imagen_pastora']."\" border=\"0\" alt=\"Descripcion\" /></div>";

//Aquí imprimo link de imagen anterior
if($anterior != false) {
echo 
"<a href=\"verfoto.php?id_pastora=".$rowNot['id_pastora']."\"><img src=\"".$rowNot['imagen_pastora']."\" width=\"50\" height=\"30\" border=\"0\" alt=\"Descripcion\" alt=\"Imagen Anterior\"/></a>";


//Aquí imprimo link de  imagen siguiente
if ($siguiente 1) {
$rowNot2 mysql_fetch_array($sqlQueryNot2);
echo 
"<a href=\"verfoto.php?id_pastora=".$rowNot2['id_pastora']."\"><img src=\"".$rowNot2['imagen_pastora']."\" width=\"50\" height=\"30\" border=\"0\" alt=\"Descripcion\" alt=\"Imagen Siguiente\"/></a>";
}

?>