PDA

View Full Version : PHP include


TheRambo
09-24-2007, 12:20 AM
I know files can be includued with php, server side language. So what code would i use if i wanted to make the one layout and get php to call for example into the content part, an html file so it display that info?

Pennimus
09-24-2007, 12:27 AM
http://www.php.net/include/

TheRambo
09-24-2007, 12:09 PM
thanks for the link but i already knew you would use <? include("filename.php") ?> etc. But what im looking for is to get the include to change a content part on the single web page when a hyperlink is hit. E.g im on the news page so there fore the news is shown then i hit say 'team' section it will load the team section in the mian content part.

Pennimus
09-24-2007, 01:03 PM
Ah,for that you will need JavaScript. You will either need to use AJAX to dynamically query the server, or load all the includes at once and simply use a normal show/hide layer system to show the right one when a link is clicked.

Google searches yield plenty of info on the former and many example scripts of the latter.

montanaflynn
09-24-2007, 05:23 PM
Or you could do it in php using case statements... look at this code!

Links
<ul>
<li><a href="facts.php?load=x&thc=hemp">Hemp</a></li>
<li><a href="facts.php?load=x&thc=legal">Legal</a></li>
<li><a href="facts.php?load=x&thc=health">Health Risks</a></li>
<li><a href="facts.php?load=x&thc=tobacco">Tobacco Vs. Cannabis</a></li>
<li><a href="facts.php?load=x&thc=qoute">Qoutes</a></li>
</ul>

Include Area
<?php

$page_choice = $_GET['thc'];
switch($page_choice) {
case "hemp": include ("http://www.totallyhigh.com/v4/facts/hemp.php"); break;
case "legal": include ("http://www.totallyhigh.com/v4/facts/legal.php"); break;
case "qoute": include ("http://www.totallyhigh.com/v4/facts/qoutes.php"); break;
case "health": include ("http://www.totallyhigh.com/v4/facts/health.php"); break;
case "tobacco": include ("http://www.totallyhigh.com/v4/facts/tobacco.php"); break;
default: echo "<b>Please select a category!</b>
";
}

?>

Pennimus
09-24-2007, 08:15 PM
That won't change the content area of a page asynchronously like the OP appears to want.