Scripting a dynamic navigational menu (php) for a non-database site. Using the following menu: First | Prev | Viewing 15-of- 16 | Next | Last Where: First is always the first file in the directory Last is always the last file in the directory Viewing is not an active link. Previous and next work as they should work The initial page load is a random file between first and last. My question is how would you handle previous when the first file is diplayed? And how would you handle next when the last file is displayed? Making them non-active seems to be beyond my current skills so the choices seem to be: Previous defaults to 1 when 1 is the current file or it loops to last. and Next defaults to last when last is the current file or it loops to 1. Tell me what you think.
Dont use PHP so cannot give the exact code but you could create a datatable or array of all the files in a randomised order and then page through them - could hold the array in a session variable or cookie or such
yes, thats a possibility or just make 1 variable: maxPages (nr of pages) and call your pages like 0.htm to MaxPages.htm and then just randomize a nr and load pageNR.htm on your homepage if current page is 0 don't href the 'previous' ancher and if page is same as your maxPages integer, don't href the 'next' ancher. don't know PHP but should be something like: currentpage = random number maxPages=10 if currentpage > 0 hrefPrevious=currentPage-1 if currentPage < maxPages hrefNext=currentPage+1 <a href="%hrefPrevious%"> Go Back </a> <a href="%hrefNext%"> Next </a>
OK, guys, how about this: <?php if ($current_page != 1) {echo "<a href='$first_page_url'>First</a> |";} else {echo "First |";} echo "<a href='$prev_page_url'>Prev</a> |"; echo " Viewing $page_no -of- $max_pg "; echo "| <a href='$next_page_url'>Next</a>"; if ($current_page != $max_pg) {echo "| <a href='$last_page_url'>Last</a>";} else {echo "| Last";} ?> PM me if you need further inspiration!
Hy ther, all! AstarothSolutions, read his original post - he did not ASK for code to create a random order of files - he asked for code that would handle disabling the controls in the case of first and last page. And that's what the code I posted does.
Chrissy I have copied that code and will take a look at it a bit later. Whether it works or not Thanks for trying. I will followup in this thread.