Jump to content


Photo

PHP and Tables


  • Please log in to reply
8 replies to this topic

#1 cappsie

cappsie
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 03 August 2006 - 05:16 PM

Hi

I have a page that is contained within a large table.

I have been wanting to swtich to php for the convenience of not having to edit lots of pages.

Alas it has not proven sucessful - I only want to use very simple php to call in to my main page php pages/docs.

For some reason I am having trouble doing this as when I design the main page with the tag:
<div class="body"><?php @ require_once ("$page.php"); ?></div>

It only loads half the page - the tutorials I have read haven't made good sense.

Is there a step by step guide around here that includes a "rule of thumb" and "best practice" guide?

alternatively if someone fancies helping me out it would save me much time - it is only very simple my aim :)

I have 6 main page links and within each page are many other links -
the main (parent) pages need to be able to list the child links and the child links have to have the ability to 'call' the php info pages into and below those child links.

I hope that is clear  :-\

Anyways thanks in advance
:)

Adam

#2 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 03 August 2006 - 05:42 PM

Try:

<?php require_once("page.php"); ?>

#3 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 03 August 2006 - 05:43 PM

Also have you considered using "include"?

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

#4 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 03 August 2006 - 05:44 PM

Oh and unless the same file is going to be included more than once, you can just use require()

#5 Ifa

Ifa
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts
  • LocationRauma, Finland

Posted 03 August 2006 - 05:45 PM

it's the $
I'm just a guy who likes to code for fun...

#6 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 03 August 2006 - 05:46 PM

Thats what I figured.

#7 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 03 August 2006 - 05:50 PM

The main diff between include and require is
if an include fails to include, the script continues
if a require fails to include, the script stops
Tell me the problem, I will try tell you the solution

#8 Ifa

Ifa
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts
  • LocationRauma, Finland

Posted 03 August 2006 - 05:51 PM

Require returns a fatal error, thus halting the script half way. But cose of that @ you don't see the error... Include would just produce a warnig, and let the script run to it's end.

I'm slow at typing  ;D
I'm just a guy who likes to code for fun...

#9 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 03 August 2006 - 06:12 PM

I think most of that makes sense.

Your require call is a little off however.  Try:
<div class="body"><?php @require_once ("page.php"); ?></div>

If you're including a dynamic page, you can do this:
<div class="body"><?php @require_once ($page . ".php"); ?></div>

Info: PHP Manual





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users