Simple script sample(s) would be helpful too. Thanks.
Code: Select all
// Calucate offsets for prev and next links
$total_results = mysql_result(mysql_query("SELECT COUNT(*) FROM $table"),0);
$prev = $row['id']-1;
$next = $row['id']+1;
$sqloffsetp = "SELECT * FROM $table WHERE id='$prev'";
$sqloffsetn = "SELECT * FROM $table WHERE id='$next'";
$sqloffsetf = "SELECT * FROM $table ORDER BY date LIMIT 1";
$sqloffsetl = "SELECT * FROM $table ORDER BY date DESC LIMIT 1";
$resoffsetp = mysql_query($sqloffsetp);
$resoffsetn = mysql_query($sqloffsetn);
$resoffsetf = mysql_query($sqloffsetf);
$resoffsetl = mysql_query($sqloffsetl);
$testp = mysql_fetch_assoc($resoffsetp); //prev
$testn = mysql_fetch_assoc($resoffsetn); //next
$testf = mysql_fetch_assoc($resoffsetf); //first
$testl = mysql_fetch_assoc($resoffsetl); //last
//MYSQL ENDS
nextprev();Code: Select all
function nextprev() // <<PREV 10 out of 20 images NEXT>>
{
global $row, $table, $testp, $testf, $testn, $testl, $total_results;
echo '<div align="center">';
if ($row['id'] != 1) {
echo "<a href='" . $_SERVER['PHP_SELF'] ."?pix=". $testf['name'] ."'><FIRST </a> ";
}
if (isset($testp['id'])) {
echo "<a href='" . $_SERVER['PHP_SELF'] ."?pix=". $testp['name'] ."'><<PREV</a> ";
}
echo $row['id'] .' out of '. $total_results .' images ';
if (isset($testn['id'])) {
echo "<a href='". $_SERVER['PHP_SELF'] ."?pix=". $testn['name'] ."'>NEXT>></a>";
}
if ($row['id'] != $total_results) {
echo "<a href='". $_SERVER['PHP_SELF'] ."?pix=". $testl['name'] ."'> LAST></a>";
}
echo '</div><br>';
}