[solved] PHP Includes and HTML

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
davidjwest
Forum Commoner
Posts: 67
Joined: Sat Nov 06, 2004 5:26 am
Location: Leeds, Yorkshire, England

[solved] PHP Includes and HTML

Post 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]
Last edited by davidjwest on Mon Apr 18, 2005 4:13 pm, edited 1 time in total.
davidjwest
Forum Commoner
Posts: 67
Joined: Sat Nov 06, 2004 5:26 am
Location: Leeds, Yorkshire, England

Post by davidjwest »

Thanks feyd :oops:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
thallish
Forum Commoner
Posts: 60
Joined: Wed Mar 02, 2005 11:38 am
Location: Aalborg, Denmark

Post 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
davidjwest
Forum Commoner
Posts: 67
Joined: Sat Nov 06, 2004 5:26 am
Location: Leeds, Yorkshire, England

Post 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!
Post Reply