Thread: Linking Porblem

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    70
    Rep Power
    15
    HI Guys,

    Straight to the problem.

    I have a page which has links to over 40 pages. I would have seen sites using this kind of php programming, ie www.test.com/test.php3?name=raaj I want to know what are the functions to be used and how i use the variable $name in the test.php3 file.

    Raaj

    ------------------
    A designer with creative skills.
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    Raj,

    What are you trying to do?.

    <<www.test.com/test.php3?name=raaj >>

    Through above link you can pass value to $name varaible and depend upon value you are passing to the test.php3,you can call some functions.

    eg: test.php3

    <?php3
    if ($name=="raj"){
    #call your function here.

    }
    ?>




    ------------------
    SR -
    shiju.dreamcenter.net
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    70
    Rep Power
    15
    OK, Let me put it straight.

    I have a menu file which links to around 40 files. I have used the normal way, ie i have 40 files with the header and footer called in as include files.

    But I wanted to use more of php, where i pass a value with the link in the menu file which gets the appropriate file in my template. How do i do it.

    Raaj
  6. #4
  7. No Profile Picture
    Web Weaver
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 1999
    Location
    Australia
    Posts
    64
    Rep Power
    15
    If I understand you correctly, here is what I would do to achieve what you want.

    First make a the template page (I will pretend it is called template.php)

    Next, make all your links point to something like this: /template.php?name=pagename

    Now in your actual template.php file work out where you want the pagename file to be included and put this in:

    <?
    include ("$name.txt");
    ?>

    And thats it! Just make sure that any files you want included have the same name as you put in the "?name=pagename" query string. All files should have a .txt extension (you can change that easily though)

    I hope that is not too confusing...

    Good Luck

    Stephen.
    www.nfsworld.net
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    Ontario, Canada
    Posts
    498
    Rep Power
    18
    Well, for starts you can add
    <?php_track_vars?> to the top line of your test.php3 document. This automatically sets variables based on the Query string (eg; test.php3?name=raaj sets $name to 'raaj').
    Also, you might put a switch() inside the file to call different includes/functions.
    eg;
    <?php_track_vars?>
    <?php
    switch($name) {
    case "raaj":
    // call whatever you want for
    // the name 'raaj' here
    break;
    ... call as many case/break's as you want
    }
    ?>

Similar Threads

  1. how to resolve linking error
    By intelchip in forum C Programming
    Replies: 6
    Last Post: October 7th, 2004, 02:09 PM
  2. probs linking functions in a header
    By Jimsta in forum C Programming
    Replies: 3
    Last Post: February 13th, 2004, 08:04 AM
  3. Google experts and linking
    By enzo250gto in forum Dev Shed Lounge
    Replies: 9
    Last Post: June 9th, 2003, 08:08 PM
  4. stopping image linking
    By trahma in forum Apache Development
    Replies: 9
    Last Post: February 8th, 2002, 08:57 PM
  5. What exactly ARE linking tables?
    By MaxC in forum MySQL Help
    Replies: 1
    Last Post: August 30th, 2001, 04:33 PM

IMN logo majestic logo threadwatch logo seochat tools logo