links with php

Discussion in 'Web Design & Coding' started by CHiLLaXen, Jan 30, 2004.

  1. CHiLLaXen

    CHiLLaXen hypnotika

    Messages:
    107
    Location:
    Minnesota
    Ok, I have a site that uses some php coding. The problem is that I want to create one page that generates everything. I want it to get the info from the url and produce the right content. Say like, I have a index.php (which loads the stuff I posted when you first enter) file and there is a link to the faq page, I want to click on the link ( something like <a href="index.php?faq>faq</a>)

    then the index.php file will produce the faq file instead of the stuff I posted.

    do you get what I'm saying? sorry, I really think of a way to explain it.

    Well kinda like the ntfs main page, the links are like

    "index.php?action=news&catid=...."
     
  2. NetRyder

    NetRyder Tech Junkie Folding Team

    Messages:
    13,256
    Location:
    New York City
    Yeah, so basically you divide your index.php page into blocks of code, such that each block generates code for a certain section.
    Your links would look something like index.php?page=faq or index.php?page=images and so on.

    Your index.php page would then look something like:
    Code:
    if($page == faq) {
     // All the code generated specific to the FAQ page
    }
    else if ($page == images) {
     // All the code generated specific to the Images page
    }
    else {
     // The page that should be displayed by default if no variable is passed 
    }
    
    You could also use a switch/case structure rather than if/else if you feel more comfortable with that.
     
  3. j79zlr

    j79zlr Glaanies script monkey Political User

    Messages:
    2,725
    Location:
    Chicago
  4. CHiLLaXen

    CHiLLaXen hypnotika

    Messages:
    107
    Location:
    Minnesota
    cool thx, I got it to work