brighton Posted May 23, 2006 Share Posted May 23, 2006 Here is the question:I can return my results from the database as a list and each result on the list have a detail info page where I can go when I click on the result. I want to make next / previous page links from these detail pages that will go from one detail page to another without returning back to the list.Do you have any idea how to do that? Quote Link to comment https://forums.phpfreaks.com/topic/10246-linking-the-results-in-different-pages/ Share on other sites More sharing options...
samshel Posted May 23, 2006 Share Posted May 23, 2006 Hello,On the details page you would have id for the current item shown.Fire a query from the database which will give you id of previous item from the list and next item from the list.You will have to take care that these queries should be sorted using the same field which you have used in main page query...For ex: suppose your main results page has a query like this$sql = "select * from products where category ='1' order by product_id";in your details page , you fire 2 queries//for previous id$prev_sql = "select * from products where category ='1' and product_id < '".$id."'order by product_id limit 1";this will give you id of the previous item//for next id$next_sql = "select * from products where category ='1' and product_id > '".$id."'order by product_id limit 1";this will give you id of the next itemWhen u have both previous and next id's , you can show hyperlinks like this<a href='details.php?id=<?php echo $previous_id;?>'> and<a href='details.php?id=<?php echo $next_id;?>'>hth Quote Link to comment https://forums.phpfreaks.com/topic/10246-linking-the-results-in-different-pages/#findComment-38176 Share on other sites More sharing options...
brighton Posted May 23, 2006 Author Share Posted May 23, 2006 Thank you very much. It worked. For the ones who wants to use this, just remember to order the previous link query descending.Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/10246-linking-the-results-in-different-pages/#findComment-38413 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.