Page 3 of 3 FirstFirst 123
Results 21 to 28 of 28

Thread: Subnavigation.

  1. #21
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    See if this works for you, you need prototype.

    Demo: http://calebmingle.com/subnav/

    index.html:

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <
    html xmlns="http://www.w3.org/1999/xhtml">

        <
    head>
            <
    meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <
    title>Subnavigation Test</title>
            
            <
    script type="text/javascript" src="js/prototype.js"></script>
            <
    script type="text/javascript" src="js/scriptaculous.js"></script>
            
            <
    script type="text/javascript">
                function 
    change_nav(nav) {
                    new 
    Ajax.Updater('subnav''subnav.php?nav=' nav);
                }
                
                
    change_nav('home');
            </
    script>

        </
    head>

        <
    body>
            <
    a href="#" onclick="javascript:change_nav('home');">Home</a> || <a href="#" onclick="javascript:change_nav('us');">About Us</a> || <a href="#" onclick="javascript:change_nav('habbo');">Habbo</a> <br /><hr /><br />
            <
    div id="subnav"></div>
        </
    body>

    </
    html
    subnav.php

    PHP Code:
    <?php
    // 
    //  subnav.php
    //  Subnavigation Script 
    //  
    //  Created by Caleb Mingle on 2009-08-12.
    //  Copyright 2009 MacDowell Diesel Performance. All rights reserved.
    // 


    // ===========================================================
    // = Switches the navigation based on what the user provides =
    // ===========================================================

    switch($_GET["nav"]) {
        case 
    "home":
            echo 
    '<a href="home.php">Home</a> | <a href="home2.php">Other Home</a>';
            break;
        
        case 
    "us":
            echo 
    '<a href="about.php">About Us</a> | <a href="contact.php">Contact Us</a>';
            break;
            
        case 
    "habbo":
            echo 
    '<a href="guides.php">Guides</a> | <a href="badges.php">Badges</a>';
            break;
    }

  2. #22
    Join Date
    Apr 2009
    Location
    United Kingdom
    Posts
    1,111
    Tokens
    100

    Latest Awards:

    Default

    Caleb why do you use case switch etc.

    if / else is faster lol.

    But good job for helping.

  3. #23
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Quote Originally Posted by BoyBetterKnow View Post
    Caleb why do you use case switch etc.

    if / else is faster lol.

    But good job for helping.
    I love how you try and correct me, like you think you know better. I'm sorry, but you're wrong.

    Thanks for the "good job for helping though".


  4. #24
    Join Date
    Apr 2009
    Location
    United Kingdom
    Posts
    1,111
    Tokens
    100

    Latest Awards:

    Default

    Quote Originally Posted by Dentafrice View Post
    I love how you try and correct me, like you think you know better. I'm sorry, but you're wrong.

    Thanks for the "good job for helping though".

    Lmao I wasn't trying to correct you. I just read that if/else is faster.

    I don't know better, you're a better coder than me by far lol.

    You did switch($nav); without defining what $nav is. Please re run the tests for me..

  5. #25
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Just because you read it, doesn't mean it's true. And going around telling someone, "if/else is faster", when you.. yourself.. haven't tried it.. is plain stupid.


  6. #26
    Join Date
    Apr 2008
    Location
    Derby
    Posts
    4,668
    Tokens
    262

    Latest Awards:

    Default

    okay guys... Thanks for your help anyway :p

  7. #27
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Is my script not what you wanted it to do? lol.

  8. #28
    Join Date
    Apr 2009
    Location
    United Kingdom
    Posts
    1,111
    Tokens
    100

    Latest Awards:

    Default

    Yeh. Neither if / else or case seem faster

    IF (Just with ifs, no elses, works nicely)
    http://www.youtubeuktop40.com/bench/...k-1.2.7/if.php

    Case
    http://www.youtubeuktop40.com/bench/...1.2.7/case.php

    But if you go onto phpbench, apparantly case is faster. I don't see that But it's stopped me from saying that either are faster.

Page 3 of 3 FirstFirst 123

Posting Permissions

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