Page 1 of 1

[solved] PHP Includes and HTML

Posted: Sat Apr 16, 2005 3:12 pm
by davidjwest
I'm writing a site using HTML and I want to use PHP includes to generate the page content, so it changes when the user clicks on the menu links.

Code: Select all

<div class="menu">
<b>Home >></b>
<a href="?action=faq" style="text-decoration:none"> FAQ >></a>
</div>

<?php
if ($_GET['action'] == 'faq')
 {
  include("faq.php");
 }
?>
The menu is included in a CSS div (I've not copied all the code, just what I think is relevant) and when the user clicks a link I am using the $_GET to generate the new frame content.

Here's the include file for "faq.php" (I've tried calling it faq.html as well with no effect).

Code: Select all

&lt;html&gt;
&lt;body&gt;
&lt;div class=&quote;second&quote;&gt;
&lt;p&gt;This is me testing some php includes to build up the screens, the FAQ should be ready in the next week or so, in the meantime please visit the forums if you want to find out more or ask questions etc&lt;/p&gt;
&lt;/div&gt;
The above is HTML, I have tried removing the html tags with no effect.

At the moment, something very odd is happening, pleas help. If you want to take a look the URL is http://www.pit-stop.org/

Hope this makes sense and you can see what I'm trying to do! Is it possible?


feyd | Please review how to post code using

Code: Select all

and

Code: Select all

tags. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Sat Apr 16, 2005 3:23 pm
by davidjwest
Thanks feyd :oops:

Posted: Sat Apr 16, 2005 3:25 pm
by feyd
your html output on the pages looks very odd... the index, has a non-terminated comment and a trailing ?> .. the "faq" page has two opening <html> tags.

Posted: Sat Apr 16, 2005 3:35 pm
by thallish
well your incude file also specifies html tags so if you look at your page source you'll see that you got four html start tags involved and thats certainly wrong try sorting that out :wink: and also you got two body start tags.

the way I do it is like the following:

What I got is:

A file that gets included with functions that specify all the necessary stuff
so I don't need to do that on every single page.

Different files that includes content

Then on top on the pages I just call function for the start html tag, the header, and the start body tag

Then the content gets specified

Then I call a function for end tags for body and html

hopes this will help you

regards thallish

Posted: Mon Apr 18, 2005 4:14 pm
by davidjwest
I managed to work it out with trial and error!

The PHP had to be before any of the HTML and that seemed to fix it, however I messed around with so many things that I might have done something else as well!

Anyway, thanks everyone!