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.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

^ 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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.