Re: [PHP] Creating 'Previous - Next Buttons' Logic - Novice Question
""Daniel Brown"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] On 6/15/07, revDAVE <[EMAIL PROTECTED]> wrote: Novice Question: I would like to create a set of pages that could use some kind of logic to have "previous - next buttons "so that when the button was clicked it would automatically go to the next page - or the previous page. I know very little about PHP ... however, I am hoping that there is some kind of preset " open source" php code that I might be able to use. I can envision something like this: - An 'include page' that might store an array of the list of pages such as: start array... pos1 = page1.htm pos2 = page17.htm pos3 = page5.htm etc. stop array... - then a variable could be set for the current page such as: thispage = 2 - Place on the array equals position 2 (page17.htm) then the next button would add 1 to the current place on the array- (pos3) - and the previous button would be minus 1 place on the array - (pos1) ... that type of thing Q: Is there any "open source" code template that I can check out like this? -- Thanks - RevDave [EMAIL PROTECTED] [db-lists] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php There are several ways to do this, but here's one way: << Previous\n"; } if($i != (count($page) - 1)) { echo "Next >>\n"; } include('page'.$i.'.htm'); ?> -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 Totally would work for his purposes but let's clean it up a bit for a beginner. $page = array('page1.htm','page17.htm','page5.htm'); // array of the pages you have if(isset($_GET['page_num'])) // a current page number has been set in the url { $i = $_GET['page_num']; // set variable i to the current page number if($i != (count($i)-1)) // if the current page number isnt the last entry in the array display next echo "Next >>\n"; if($i != 0) // if the current page isn't the first page display previous echo "<< Previous\n"; } include('page'.$i.'.htm'); // show the current page you're at ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating 'Previous - Next Buttons' Logic - Novice Question
revDAVE wrote: Novice Question: I would like to create a set of pages that could use some kind of logic to have "previous - next buttons "so that when the button was clicked it would automatically go to the next page - or the previous page. I know very little about PHP ... however, I am hoping that there is some kind of preset " open source" php code that I might be able to use. I can envision something like this: - An 'include page' that might store an array of the list of pages such as: start array... pos1 = page1.htm pos2 = page17.htm pos3 = page5.htm etc. stop array... - then a variable could be set for the current page such as: thispage = 2 - Place on the array equals position 2 (page17.htm) then the next button would add 1 to the current place on the array- (pos3) - and the previous button would be minus 1 place on the array - (pos1) ... that type of thing Q: Is there any "open source" code template that I can check out like this? -- Thanks - RevDave [EMAIL PROTECTED] [db-lists] Why don't you google for 'php pagination' ?? http://www.google.com/search?&q=php%20pagination only 1.2 millions results to look through. I'm sure that you can add words to that search phrase to narrow the search also, try searching the archives, I just wrote a posted a link to a nice example on how to do pagination. here is the link to the source. for highlighting purpose only. http://www.cmsws.com/examples/php/pagination/example1.php source is available here. http://www.cmsws.com/examples/php/pagination/example1.phps It mainly deals with pagination based off information retrieved from a DB. But, it could be adopted to work with arrays also. -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating 'Previous - Next Buttons' Logic - Novice Question
On 6/15/07, revDAVE <[EMAIL PROTECTED]> wrote: Novice Question: I would like to create a set of pages that could use some kind of logic to have "previous - next buttons "so that when the button was clicked it would automatically go to the next page - or the previous page. I know very little about PHP ... however, I am hoping that there is some kind of preset " open source" php code that I might be able to use. I can envision something like this: - An 'include page' that might store an array of the list of pages such as: start array... pos1 = page1.htm pos2 = page17.htm pos3 = page5.htm etc. stop array... - then a variable could be set for the current page such as: thispage = 2 - Place on the array equals position 2 (page17.htm) then the next button would add 1 to the current place on the array- (pos3) - and the previous button would be minus 1 place on the array - (pos1) ... that type of thing Q: Is there any "open source" code template that I can check out like this? -- Thanks - RevDave [EMAIL PROTECTED] [db-lists] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php There are several ways to do this, but here's one way: << Previous\n"; } if($i != (count($page) - 1)) { echo "Next >>\n"; } include('page'.$i.'.htm'); ?> -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating 'Previous - Next Buttons' Logic - Novice Question
Hi, Friday, June 15, 2007, 9:53:24 PM, you wrote: > I know very little about PHP ... however, I am hoping that there is some > kind of preset " open source" php code that I might be able to use. There is the Pear pagination package which can do this, although not quite in the way you want it done in your example. Search pear.php.net for it if you want. > - An 'include page' that might store an array of the list of pages such as: > start array... > pos1 = page1.htm > pos2 = page17.htm > pos3 = page5.htm > etc. > stop array... > - then a variable could be set for the current page such as: > thispage = 2 - Place on the array equals position 2 (page17.htm) Can I take it from this example that your pages should not be in sequence then? I.e. instead of going page1, page2, page3, instead they should go page1, page17, page5, etc? If so, why? :) Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk "Never trust a computer you can't throw out of a window" -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Creating 'Previous - Next Buttons' Logic - Novice Question
Novice Question: I would like to create a set of pages that could use some kind of logic to have "previous - next buttons "so that when the button was clicked it would automatically go to the next page - or the previous page. I know very little about PHP ... however, I am hoping that there is some kind of preset " open source" php code that I might be able to use. I can envision something like this: - An 'include page' that might store an array of the list of pages such as: start array... pos1 = page1.htm pos2 = page17.htm pos3 = page5.htm etc. stop array... - then a variable could be set for the current page such as: thispage = 2 - Place on the array equals position 2 (page17.htm) then the next button would add 1 to the current place on the array- (pos3) - and the previous button would be minus 1 place on the array - (pos1) ... that type of thing Q: Is there any "open source" code template that I can check out like this? -- Thanks - RevDave [EMAIL PROTECTED] [db-lists] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php