• Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Needing PHP Help

Rindiny

Fwee!!!^^
  • 74
    Posts
    18
    Years
    • Age 34
    • Seen Sep 5, 2010
    Hello, I'm requiring some PHP help on a small project I'm working on. I'm basically writing up a mini-pokedex script for a friend.


    Code:
    <html>
    <head>
    
    <title>MiniDex - <?php echo("$pokemon"); ?></title>
    </head>
    <body>
    <?
    $pokemon = "Bulbasaur";
    ?>
    </body>
    </html>

    What's my problem? I declared the variable in my PHP script, but strangely it won't show up in my title. How do I fix this?
     
    I removed the quotation marks that were in the <title> tag, and it didn't work.
     
    Alright, I finally got it to work. Thanks Tyler!

    EDIT: I'm planning to use the ?page= script that Koroku has posted. How can I edit the values of $pokemon to match the variable declared to find the page?
     
    Code:
    <?
    //Declare Main PHP Variables
    $news = "main.txt";
    $error = "404.txt";
    $ext = ".txt";
    //Include Variables
    if(!isset($_GET['pokemon'])){
    include $news;
    }
    elseif($_GET['page'] == "main") {
    include $news;
    }
    elseif(isset($_GET['pokemon']) && file_exists($_GET['pokemon'].$ext)){
    include $_GET['pokemon'].$ext;
    }
    else{
    include $error;
    }  
    ?>

    Example:
    ?pokemon=deoxys

    Title:

    Minidex - Deoxys

    How can I make it so by default the variable $pokemon turns into the page the user is currently on without me having to declare this option all the time?
     
    I'm declaring $001 as a variable, and suddenly, it gives me a PHP error about declaring a variable as a number.
     
    I'm declaring 001 as a variable because it's a Pokemon. What do you mean number itself? Do you mean "1" instead?
     
    Example:
    ?pokemon=deoxys

    Title:

    Minidex - Deoxys

    How can I make it so by default the variable $pokemon turns into the page the user is currently on without me having to declare this option all the time?
    The code isn't right.
    Code:
    <?
    //Declare Main PHP Variables
    $news = "main.txt";
    $error = "404.txt";
    $ext = ".txt";
    //Include Variables
    if(!isset($_GET['pokemon'])){
    include $news;
    }
    elseif($_GET['pokemon'] == "main") {
    include $news;
    }
    elseif(isset($_GET['pokemon']) && file_exists($_GET['pokemon'].$ext)){
    include $_GET['pokemon'].$ext;
    }
    else{
    include $error;
    }  
    ?>
    You forgot one.

    Stick that in index.php and going to index.php?pokemon=bulbasaur will load bulbasaur.txt

    If you want to have it print out the Pokemon, then you can do something like this: (Not the most secure, as I'm too lazy to deal with that right now)
    Code:
    <?
    $pokemon = $_GET['pokemon'];
    ?>
    Then whenever you want to print the name,
    Code:
    <? print "$pokemon"; ?>

    So when you go index.php?pokmeon=bulbasaur

    And have $pokemon somewhere in your code, it'll print out "bulbasaur"


    (And really, the best way to do a PokeDex would be to make it MySQL based, and work that way.)
     
    I don't know any mySQL. It looks complicated. I don't know how to export data from a mySQL database into PHP code. What I mean is, if I add a piece of data saying something, say "Pikachu". I don't know how to print out the mySQL data the right way using PHP.
     
    I've tried building a text file based PokeDex, and it's not fun at all.

    And there are a lot of tutorials out there~
     
    I'm using variables for almost everything I can think of. The Pokedex was supposed to made up entirely of variables. So if I change a thing, it changes in all instead of one.
     
    And what happens when you want to add something?

    With mySQL, it's maybe... 2 minutes? Flatfile... you're talking about editing 400+?
     
    Back
    Top