PDA

View Full Version : Hmmmm... PHP +REP



myke
19-02-2007, 07:55 PM
Hey, can anyone link me to an easily understood php include tutorial, how to target it =)

ZAG
19-02-2007, 08:11 PM
What do you mean, how to target it?

Dentafrice1
19-02-2007, 08:18 PM
<?php
include "file.php";
?>


OR



<?php
include ("file.php");
?>


Or



<?php
include 'file.php';
?>


Or



<?
include "file.php";
?>


or


<?
include ("file.php");
?>



<?
include 'file.php';
?>


or



<?
$page = file_get_contents($page);
echo $page;
?>

Ini
19-02-2007, 08:38 PM
Lol, one way would of been good enough :P

Dentafrice1
19-02-2007, 10:18 PM
I know I was just bored and wanted to show all the ways to include something :P

myke
20-02-2007, 12:44 PM
Denta, I know how to include a file but how to target the include like so when you click on 'News' the include changes from including the main to 'news'

Isolde
20-02-2007, 12:56 PM
google it ?

ZAG
20-02-2007, 02:35 PM
You could just use the $_GET function



<?php

$page = $_GET['page'];

switch($page){

default:
include('main.html');
break;

case "news":
include('news.html');
break;
}

?>


If i understood you, thats what you mean.
You'd go to

index.php?page=news
to load news.html

or just index.php
to load main.html

If you mean change the included page without page load, you'd have to use AJAX.

myke
20-02-2007, 05:24 PM
yeah, that's it, thomas :) thanks! would I have to edit any of that code?

ZAG
20-02-2007, 05:41 PM
Well you'd obviously have to put it in the right part of your layout code and to add another page to it you would change it to:



<?php

$page = $_GET['page'];

switch($page){

default:
include('main.html');
break;

case "news":
include('news.html');
break;

case "anotherpage":
include("anotherpage.html");
break;
}

?>

Want to hide these adverts? Register an account for free!