0

I'm trying to get multiple variables to work in the query string with PHP.

This is my code:

<?
$programme=$_GET['programme'];
switch ($programme) {
case 12578:
    include("http://mysite1.com/programme/TopGear");
    break;
case ER:
    include("http://mysite1.com/programme/ER);
    break;
default:
    echo "page not found!!!!";
}
$hPage=$_GET['hPage'];
switch ($hPage) {
case 1:
    include("page1.php");
    break;
case 2:
    include("page2.php");
    break;
case 3:
    include("page3.php");
    break;
default:
    echo "page not found!!!!";
}

?>

I'm trying to get the code so that the URL is similar to these:
http://www.autoweek.nl/carbase_data.php?id=45405&cache=no
http://library.digiguide.com/lib/programmenextshowing/238308&hPage=2
where the query string has multiple parameters.

Feel free to improve my code, and I will test it out.
(Note that the URLs are mapped using my Apache's httpd-vhosts.conf, so they are local only to one machine, using VirtualHosts directive).

I am testing these before I manage to get a live site configuration working.

Also, if anyone knows how to, how do I rewrite the query string in the question mark to the ampersand?

Thanks! :)

2
Contributors
1
Reply
3
Views
8 Years
Discussion Span
Last Post by Airshow
0

Whitestream,

I'm trying to get the code so that the URL is similar to these:
http://www.autoweek.nl/carbase_data.php?id=45405&cache=no
http://library.digiguide.com/lib/programmenextshowing/238308&hPage=2
where the query string has multiple parameters.

Your url can't be similar to both of these examples. You must choose one or the other, and unless you want to make a lot of work for yourself, then use the first type.

The second type is generally used in MVC frameworks such as Zend or Cake and require Apache to run with mod-rewrite (or equivalent in other servers).

For your sample code, your url will be of the following format: http://www.mysite.xxx/mypage.php?programme=ER&hPage=2 .

Be aware that each $_GET element is a string, therefore you need to test with case 'ER': not case ER: .

Airshow

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.