www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > PHP

    PHP Discussion and technical support for using and deploying PHP based websites.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 10-29-2006, 01:40 PM
    mrwilson mrwilson is offline
    Registered User
     
    Join Date: Oct 2005
    Location: Knoxville Tennessee
    Posts: 74
    Hopefully Simple Switch Question

    Obviously a Newbie here. Some may recognize this script as It was graciously given to me here

    I am using the switch script to change pages within a body div dynamically.
    My basic question is, how can i get that down to a DIV level and not on a "page" level?
    http://www.lunarcafe.com/tryme/template.php

    I am using:
    <div id="body1">

    <?php
    include("inc.html");

    $page = $_GET['page'];

    switch ($page) {
    case "cats";
    include ("cats.html");
    break;

    case "dogs";
    include ("dogs.html");
    break;

    }
    ?></div>
    <div id="body2">
    <?php
    include("inc.html");

    $page1 = $_GET['page'];

    switch ($page1) {
    case "mice";
    include ("mice.html");
    break;

    case "fish";
    include ("fish.html");
    break;

    }
    ?>

    If you look at my page, menu items 2-3 apply to the first DIV, and the 4-5 menu items apply to the 2nd DIV. When I hit 4-5, the information in DIV 1 goes away and the proper files appear in Div2.
    My menu is structured like this
    <?php
    $home = $_SERVER["PHP_SELF"];
    echo "<a href=\"$home\">Home</a><br />";
    echo "<a href='http://www.lunarcafe.com/tryme/template.php?page=dogs'>The Dog page</a><br />";
    echo "<a href='template.php?page=cats'>The cat page</a><br />";
    echo "<a href='http://www.lunarcafe.com/tryme/template.php?page=mice'>The Mice page</a><br />";
    echo "<a href='http://www.lunarcafe.com/tryme/template.php?page=fish'>The Fish page</a><br />";
    ?>


    I have a feeling the answer lies in the template.php?page=fish' PAGE statement here and in $page1 = $_GET['page'] linkage as well

    Any thoughts? I want to assign the menu links to certain DIV's without changing the information in the first div? The page will be changed when I have a clue what I am doign, this page is for my own learning. There will be at least 4 DIV's

    Thanks for reading this.
    Reply With Quote
      #2  
    Old 10-29-2006, 06:28 PM
    so_is_this so_is_this is offline
    don't ask
     
    Join Date: Oct 2006
    Posts: 1,304
    Basically, it works the same way at the DIV level as at the page level -- if a file is to contain a single DIV. If you're wanting to include multiple DIVs in the same file, then you could use something like preg_match() to extract a particular DIV out of a library file of DIVs.
    Reply With Quote
      #3  
    Old 10-29-2006, 06:55 PM
    mrwilson mrwilson is offline
    Registered User
     
    Join Date: Oct 2005
    Location: Knoxville Tennessee
    Posts: 74
    I see what you are saying, but I was trying to include a file into a particular DIV from a link and have it stay there till replaced. But you have given me a vary good idea with the library or array of $DIV's. Thanks!
    Reply With Quote
      #4  
    Old 10-29-2006, 07:15 PM
    so_is_this so_is_this is offline
    don't ask
     
    Join Date: Oct 2006
    Posts: 1,304
    Quote:
    Originally Posted by mrwilson
    ... I was trying to include a file into a particular DIV from a link and have it stay there till replaced.
    That can certainly be done. All it takes is for the link to point to the current page and have a query string argument attached to the link which designates the particular DIV to be inserted. If that page is to retain that DIV even after navigating to a different page and then coming back to the current page, then you will have to save such information in either SESSION variables or in a COOKIE.
    Reply With Quote
      #5  
    Old 10-29-2006, 07:44 PM
    mrwilson mrwilson is offline
    Registered User
     
    Join Date: Oct 2005
    Location: Knoxville Tennessee
    Posts: 74
    That will be a good learning tool, the sessions and/or the cookie. I have been reading up on sessions and want to try something in that area.

    Could you give me an example of such an query string arguement attached to a link? just any example will do for me to get the idea. Thanks.
    Reply With Quote
      #6  
    Old 10-29-2006, 09:37 PM
    so_is_this so_is_this is offline
    don't ask
     
    Join Date: Oct 2006
    Posts: 1,304
    The link:
    HTML Code:
    <a href="thispage.htm?div=someid">Some Text</a>
    The code to receive the value from the link:
    PHP Code:
    <?php

    if (isset($_GET['div'])
    && !empty(
    $_GET['div'])):
        
    $div = $_GET['div'];
    else:
        
    $div = '';
    endif;

    ?>
    Reply With Quote
      #7  
    Old 10-29-2006, 10:06 PM
    mrwilson mrwilson is offline
    Registered User
     
    Join Date: Oct 2005
    Location: Knoxville Tennessee
    Posts: 74
    Excellent, thank you for being so kind.
    I see what you did, its almost exactly like a post and get form.
    Part of whats dificult with this, is that 99% of tutorials dont teach you things like "!empty" and you are left dangling wondering why things dont work. I guess thats why you download scripts, to analyze them

    Thanks again.
    Reply With Quote
      #8  
    Old 10-29-2006, 11:56 PM
    so_is_this so_is_this is offline
    don't ask
     
    Join Date: Oct 2006
    Posts: 1,304
    Salud!
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 03:24 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.