View Full Version : PHP Include help
Pazza
19-08-2008, 12:15 AM
Hey,
So, i have my index which includes a file called 'Appmenu.php'.
In Appmenu, is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dunt need one :)</title>
</head>
<body>
Please select the department you would like to be a part of:
<p>
<p>
<a href="radio.php">Radio Department</a>
<a href="news.php">News Department</a>
<a href="events.php">Events Department</a>
</body>
</html>
So, how do I make it the links load into the same include Appmenu is, as these links simply open new pages.
+rep for any help,
Cheers ;)
madchild24
19-08-2008, 12:21 AM
put it in the appmenu file? or I missunderstood what your asking..
Matt.
19-08-2008, 12:24 AM
Please delete, sorry.
Pazza
19-08-2008, 12:26 AM
put it in the appmenu file? or I missunderstood what your asking..
Okay, I have index.php, and that includes Appmenu.php
Appmenu is meant to have links to categories, and when clicked (the links), they should load into the same include Appmenu.php is, in index.php
?
Dentafrice
19-08-2008, 12:32 AM
PHP does not work like an iframe, they are not going to load by themselves like iframes do.
Source
19-08-2008, 01:00 AM
1 word. Ajax.
another. Scripaculous.
2 words. Ajax.Updater
Decode
19-08-2008, 09:20 AM
Im not quite sure what you mean, but give this a go :P
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dunt need one :)</title>
</head>
<body>
Please select the department you would like to be a part of:
<p>
<p>
<a href="index.php?p=radio">Radio Department</a>
<a href="index.php?p=news">News Department</a>
<a href="index.php?p=events">Events Department</a>
<?php
if ( isset ( $_GET['p'] ) ) {
$p = addslashes ( $_GET['p'] );
$p .= ".php";
if ( file_exists ( $p ) ) {
include ( $p );
}
else {
echo "cannot find file";
}
}
else {
echo "Please choose a department above";
}
?>
</body>
</html>
Im not 100% sure that will work as i've just wrote it out now and its not tested, but give it a try :)
Pazza
19-08-2008, 10:43 AM
That works great! The links are still there but oh well xD
+rep (if can)
Decode
19-08-2008, 11:23 AM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dunt need one :)</title>
</head>
<body>
<?php
if ( isset ( $_GET['p'] ) ) {
$p = addslashes ( $_GET['p'] );
$p .= ".php";
if ( file_exists ( $p ) ) {
include ( $p );
}
else {
echo "cannot find file";
}
}
else {
echo 'Please select the department you would like to be a part of:
<p>
<p>
<a href="index.php?p=radio">Radio Department</a>
<a href="index.php?p=news">News Department</a>
<a href="index.php?p=events">Events Department</a>';
}
?>
</body>
</html>
If you want the links removed use this code :)
Pazza
19-08-2008, 11:33 AM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dunt need one :)</title>
</head>
<body>
<?php
if ( isset ( $_GET['p'] ) ) {
$p = addslashes ( $_GET['p'] );
$p .= ".php";
if ( file_exists ( $p ) ) {
include ( $p );
}
else {
echo "cannot find file";
}
}
else {
echo 'Please select the department you would like to be a part of:
<p>
<p>
<a href="index.php?p=radio">Radio Department</a>
<a href="index.php?p=news">News Department</a>
<a href="index.php?p=events">Events Department</a>';
}
?>
</body>
</html>
If you want the links removed use this code :)
Thanks!
I need a bit more help,
Index.php has that, then that links to radio.php, so how do I make the links in radio.php do that?
I'dve tried both aboves but it just forever expands ^^
+rep for any help (unless its tom again I'd owe)
Decode
19-08-2008, 12:15 PM
It should work by using <a href="index.php?p=pagename"></a> in radio.php as long as the page you are trying to include is in the same dir as the index page :)
Pazza
19-08-2008, 12:23 PM
It should work by using <a href="index.php?p=pagename"></a> in radio.php as long as the page you are trying to include is in the same dir as the index page :)
Okay, ima try that :)
Works PERFECT :D
Ima owe u rep forever :D
<3 lool
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.