php include I think

I am having a problem wrapping my head around how to accomplish a seemingly very simple task. I dont have much experience working with php either. I have searched everywhere for a tutorial with no luck. So, here’s what I’m trying to do…

I have a sub-navigation menu within a page that looks like this

<div id="loan-types">
    <ul>
        <li><a href="fha.php">FHA Loans</a></li>
        <li><a href="203k.php">203k Loans</a></li>
    </ul>
</div>

Then, I have an area where I would like the information displayed when the corresponding link is clicked that looks like this

    <div id="guts>
            <h1>FHA Loans</h1>
            <p>Information about FHA loans</p>
    </div>

My original thought was to use php to include a separate page containing the content…

<h1>203k Loans</h1>
<p>Information about 203k loans</p>

^^ this would be an example of the page (203k.php) ^^

and when the link is clicked the contents of #guts (fha.php) will be replaced with the new content (203k.php)

I was thinking maybe using both javascript and php (specifically php include) will accomplish this.

I hope this makes sense. Like I said I’m still very new to php. Thanks in advance for your taking time to help!

[php]<?php
// index.php
$actions = array( ‘home’ => ‘pages/home.php’, //default page
‘fha’ => ‘pages/fha.php’,
‘createboard’ => ‘pages/createboard.php’,

             );

if(!isset($_GET[‘p’]) || !array_key_exists($_GET[‘p’], $actions))
$_GET[‘p’] = ‘home’; // set a default

include($actions[ $_GET[‘p’] ]);

?>[/php]

Hope this helps.
Placing this code and using links as will load the page where ever you put this code.

Sponsor our Newsletter | Privacy Policy | Terms of Service