Amigo.
La consulta donde buscamos el anterior, la condición es
< (no <=). Además creo que no está entrando nunca donde se muestra la anterior. Prueba este código:
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());
//cantidad de records encontrados. si = 1 hay anterior de lo contrario, nohay anterior.
$anterior = mysql_num_rows($sqlQueryNot);
//Aquí me quedo con la imagen anterior.
$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);
echo "<div id=\"verfoto\"><img src=\"".$rowNot2['imagen_pastora']."\" border=\"0\" alt=\"Descripcion\" /></div>";
//Aquí imprimo link de imagen anterior
if($anterior > 0) {
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>";
}
?>