Results 1 to 3 of 3

Thread: Simple PHP script help, please :)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2002
    Location
    UK
    Posts
    83

    Unhappy Simple PHP script help, please :)

    I know this is a pretty simple question but this is all I want.

    here goes, I want a script in php that if I put say:

    www.myhost.com/myscript.php?character=1

    it would come up with a page with info about character 1 (for a game site) but if I put :

    www.myhost.com/myscript.php?character=2

    it brings up a different page with info about character 2.


    and so on.

    Can anyone either make this script or send me somewhere that can tell me how to do it...

    Thanks

  2. #2
    Fanatic Member Gimlin's Avatar
    Join Date
    Dec 2001
    Location
    Hell
    Posts
    734
    PHP Code:
    <?php
    if $_REQUEST[character] == "1"){
    print (
    "page1");
    }
    elseif 
    $_REQUEST[character] == "2"){
    print(
    "page2");
    }
    else{
    print(
    "<a href=\"myscript.php?character=1\">Page 1</a><br>");
    print(
    "<a href=\"myscript.php?character=2\">Page 1</a><br>");
    }
    ?>
    There are many ways to do this, this is the simplist example I can think of.

  3. #3
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    PHP Code:
    <?php
      
    if (!isset($_REQUEST['character'])) $_REQUEST['character'] = "";
      switch (
    $_REQUEST['character']) {
        case 
    1:
          
    // character 1 selected for viewing
        
    break;
        case 
    2:
          
    // character 2 selected for viewing
        
    break;
        default:
          
    // no character selected for viewing
      
    }
    ?>
    It is much easier if you have all the characters in a database b/c then you can just query the database for the information instead of outputting it by hand.
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width