simple previous / next code
Posted: Fri Jun 18, 2010 1:31 pm
I have image galleries divided into categories and have while statements to iterate through the result set. But when the visitor hits the last image in the set, I want the "NEXT" option to change to a "RETURN" which will return to the list of categories. If I could use ELSE with WHILE, I could do this, but ELSE doesn't work with WHILE. So I need to tell the code what to do when the loop ends.
Here is the code, such as it is. The bottom IF statement doesn't work, but it tells you what I am trying to do.
Here is the code, such as it is. The bottom IF statement doesn't work, but it tells you what I am trying to do.
Code: Select all
while ($next1 = mysql_fetch_assoc($next)){
$n = $next1[portfolio_id];
$cat_id=$next1[category_id];
echo "<a href='index.php?id=$n&c_id=$cat_id'>NEXT</a>";
}
if (!isset($next1)){
echo "<a href='index.php?cat_id=$c_id'>RETURN</a>";
}