Jump to content

generating pages with custom strings as urls


tomjones

Recommended Posts

I did not see the correlation when experimenting with the above example. More specific I am trying to generate pages with custom names from an array, like www.domain.com/page.php?foo1 and www.domain.com/page.php?foo2. I Just need to know how to create these urls with php.. thanks.
may be a switch statement is what you are wanting.

[code=php:0]<?php
function getpage($showpage) {
    switch ($showpage) {
        case "your_page":
//put the php here
        break;
        case "your_next_page":
//put another page here
        break;
    default:
//your default page
    }
}
getpage($_GET['showpage']);//you need this to execute your code
?>[/code]

A link for this would be whatever.php?showpage=your_page


Hope that helps

Tom
^ It's exactly what redarrow said.

You use the $_GET superglobal to track what link to go to. Example:

if (isset($_GET['link'])) {
   $link = $_GET['link'];
   if ($link == 3) {
       // Include links for page.php?link=3
   }
   elseif ($link == 5) {
       // page.php?link=5
   }
   else {
       die ('You are not using a valid link');
   }
}
else {
   // Show page.php
}

You can repeat the elseif statement for however many you want different stuff to show up. There are many ways of using the $_GET superglobal to create those kinds of links.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.