View Single Post
  #1 (permalink)  
Old Jul 21st, 2006, 23:11
AdRock's Avatar
AdRock AdRock is offline
SuperMember

SuperMember
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Pagination with PHP and switch statement

Hello there......I have a huge problem and have no idea how to sort it

I use a switch statement on my index.php page to display each of my pages (only some of them are shown to save space)


PHP: Select all

 <?php
 
switch ($_GET['page'])
{
 
case 
"contact":
include(
'contact.php');
break;
case 
"news":include('news.php');break;
default:
include(
'home.php');
}
?>
I have a pagination script to display a set number of record per page. The first page displays ok showing http://www.mysite.com/index.php?page=newsitem but when i click on the next link it defaults back to the default page http://www.mysite.com/index.php?page=home (obviuosly because the switch statement isn't set up to handle it)
The link that appears in the browser window is http://www.mysite.com/index.php?page=newsitem?limit=2&page=2 but the default page is displayed.

How do I sort this problem out? Do I need to use nested switch and if so how do I do it.

The pagination script I am using is from http://www.allsyntax.com/tutorials/P...with-PHP/2.php

I am sure if I didn't use the switch statement it would work but it seems very inefficient (been doing visual basic for the last 2 years at college).

I have seen t done in dozens of websites including how google does it searches and need to know how to do it.

Please help as I'm tearing my hair out here

Last edited by AdRock; Jul 21st, 2006 at 23:51.
Reply With Quote