Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: PHP Extension

  1. #1
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP Extension

    I have not been able to find this so hopefully someone here can help me...how do I make it so that my navigation will be something like this..

    Tutorials:http://www.site.com/tutorials.php?id=..
    Downloads:http://www.site.com/downloads.php?id=..

    ---------------

    Also I am trying to set up a search feature, how do I make direct the search a specific database?

  • #2
    New Coder
    Join Date
    Apr 2006
    Location
    Planet Earth
    Posts
    59
    Thanks
    1
    Thanked 8 Times in 8 Posts
    PHP Code:
    <?php

    function one() {
          
    //Your code here
    }

    function 
    two() {
          
    //Your code here
    }

    function 
    three() {
          
    //Your code here
    }

    switch(
    $op) {
        
        case 
    "one":
        
    one();
        break;

        case 
    "two":
        
    two();
        break;
        
        case 
    "three":
        
    three();
        break;

        default:
        
    one();
        break;
    }

    ?>
    Linking Examples:

    Code:
    http://mysite.com/myfile.php?op=one
    http://mysite.com/myfile.php?op=two
    http://mysite.com/myfile.php?op=three
    The default page will be fuction one.

    Or u can try this:

    PHP Code:
    <?php

    if(!isset($id)){
        die(
    "Id not set");
    } else {


    //Your code goes here.

    }

    ?>
    Last edited by zactanaz; 04-28-2006 at 01:42 AM. Reason: Added more code

  • #3
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    do i need to put that in every document? And what does the "switch" tag do when it makes it past #3?

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Best way is to use a database. Will be more efficiant too if you've got loads of files/pages.

    On the example above, once you get past 'three' it'll go to the default page, ie: one.

    So if you've got hundreds of pages, you'll have hundreds of 'case's in a switch, which wouldn't seem resourceful to me. Best way if you don't have a db is probably to use an array:

    http://uk2.php.net/array

    Then check if the page is in the array by using

    http://uk2.php.net/in_array

    PHP Code:
    /* security checks done, connected to db etc etc */
    $sql "SELECT data FROM table WHERE id='$id'";
    $query mysql_query($sql) or die(mysql_error());
    if(
    mysql_num_rows($query) == '1'){
       echo 
    'Page found, echo all info from db entry';
    }else{
       echo 
    'Page not found, show error';

    Last edited by Nightfire; 04-28-2006 at 03:38 AM.


  •  

    Posting Permissions

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