Question:

With php, say if I have a jpeg and some text in <div id="main">, and each time someone clicks ?

by  |  earlier

0 LIKES UnLike

On a link at the side bar, you are not directed to another page, but <div id="main"> and its contents (the text and jpeg) change relative to the link that is clicked on. I know I need if and else statements, but how is it all arranged?

 Tags:

   Report

1 ANSWERS


  1. This approach may harm your search engine rankings.

    You&#039;ll need a script to act as a page load handler.  I&#039;ll just call it handler.php here.

    You&#039;d do something like this (untested):

    &lt;a href=&quot;handler.php?load=page1.html&quot;&gt;Link 1&lt;/a&gt;

    &lt;a href=&quot;handler.php?load=page2.html&quot;&gt;Link 2&lt;/a&gt;

    &lt;a href=&quot;handler.php?load=page3.html&quot;&gt;Link 3&lt;/a&gt;

    And in handler.php, you&#039;d need this inside your DIV:

    &lt;?php

    if (isset($_GET[&#039;load&#039;]))

    $page = $_GET[&#039;load&#039;];

    else

    $page = &#039;default.html&#039;;

    include $_SERVER[&#039;DOCUMENT_ROOT&#039;] . &#039;/&#039; . $page;

    ?&gt;

    The use of the server variable DOCUMENT_ROOT ensures that only files relative to your local document root are accessible to the handler.  This avoids potential security holes with the user linking foreign web documents in your page or accessing arbitrary files anywhere in your file system.

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions