Bob-Marley Posted January 2, 2009 Share Posted January 2, 2009 <?php $image_query=mysql_query("SELECT id FROM images ORDER BY id DESC"); if($_GET['id'] > "1"){ $id=mysql_real_escape_string($_GET['id]); $max=mysql_num_rows($image_query); /////////NumberOfImages $back=$id-1; //////////BackID if($id < $max){ $next=$id+1; //////////NextID }else{ $id="1"; } $cur_img=mysql_fetch_array(mysql_query("SELECT src FROM images WHERE id='$id'")); echo"<img src=\"".$cur_img[src]."\"><br>"; if($back){ echo"<a href=\"book.php?id=".$back."\">Back</a>"; } if($next){ echo"<a href=\"book.php?id=".$next"\">Next</a>"; } ?> try that , make a table with id and src then insert 1 row per image and src is the URL to the image Quote Link to comment https://forums.phpfreaks.com/topic/138910-the-next-or-previous-valid-sql-value/page/2/#findComment-728346 Share on other sites More sharing options...
Maq Posted January 2, 2009 Share Posted January 2, 2009 Bob-Marley, If you read the previous posts we decided not to do that because some of the id's don't exist because they have been deleted. Quote Link to comment https://forums.phpfreaks.com/topic/138910-the-next-or-previous-valid-sql-value/page/2/#findComment-728350 Share on other sites More sharing options...
Bob-Marley Posted January 2, 2009 Share Posted January 2, 2009 Ok just posting my opinion Quote Link to comment https://forums.phpfreaks.com/topic/138910-the-next-or-previous-valid-sql-value/page/2/#findComment-728352 Share on other sites More sharing options...
Maq Posted January 2, 2009 Share Posted January 2, 2009 Ok just posting my opinion And here's mine, you should read the previous posts so you don't post redundant suggestions that have already been rendered useless. Quote Link to comment https://forums.phpfreaks.com/topic/138910-the-next-or-previous-valid-sql-value/page/2/#findComment-728362 Share on other sites More sharing options...
Zeradin Posted January 16, 2009 Author Share Posted January 16, 2009 I'm using these $newidquery = "SELECT id FROM yearbook WHERE id < $id AND year = 2009 AND visible = 0 ORDER BY id DESC LIMIT 1"; $newidquery2 = "SELECT id FROM yearbook WHERE id > $id AND year = 2009 AND visible = 0 ORDER BY id ASC LIMIT 1"; but now I want to get the next and prev values for alphabetical order from the name column. How would I do that? Quote Link to comment https://forums.phpfreaks.com/topic/138910-the-next-or-previous-valid-sql-value/page/2/#findComment-738476 Share on other sites More sharing options...
Zeradin Posted January 18, 2009 Author Share Posted January 18, 2009 bump? Quote Link to comment https://forums.phpfreaks.com/topic/138910-the-next-or-previous-valid-sql-value/page/2/#findComment-739856 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.