Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 03-16-2009, 06:37 AM Include Function
Junior Talker

Posts: 4
Name: Chris
Trades: 0
Hey, I feel a bit stupid asking this question but i've drawn a blank im using the include function to make a website having heading/nav/footer but I cannot for the life of me remember the code thats needed to open the links in the nav bar in the main section i remember doing it years ago but just cant seem to remember now. http://handweaving.seitservices.com.au/index3.php is the site im testing it on. I know the main.php isnt suppose be that just cant remember what it is suppose to be.

Here is what I have.

PHP Code:
<table border="1" width="100%" height="0">
   <tr>
      <td height="120" width="100%" colspan="2"><?php include('heading.php');?> </td>
   </tr>
   <tr>
      <td height="0" width="20%"><?php include('leftmenu.php');?> </td>
      <td height="0" width="80%"><?php include('main.php');?> </td>
   </tr>
   <tr>
      <td height="50" width="100%" colspan="2"><?php include('bottom.php');?> </td>
   </tr>
</table>
leftmenu.php (not suppose to be what it is either)

HTML Code:
<a href="../index.php">Home</a><p>
<a href="../aboutus.php">About Us</a><p>
<a href="../products.php">Products</a><p>
<a href="../gallery.php">Gallery</a><p>
<a href="../contactus.php">Contact Us</a><p>
claffin is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-16-2009, 06:48 AM Re: Include Function
dark_lord's Avatar
Experienced Talker

Posts: 41
Name: Parijat Roy
Location: INDIA-KOLKATA
Trades: 0
Quote:
Originally Posted by claffin View Post
Hey, I feel a bit stupid asking this question but i've drawn a blank im using the include function to make a website having heading/nav/footer but I cannot for the life of me remember the code thats needed to open the links in the nav bar in the main section i remember doing it years ago but just cant seem to remember now. http://handweaving.seitservices.com.au/index3.php is the site im testing it on. I know the main.php isnt suppose be that just cant remember what it is suppose to be.
couldn't understand anything
__________________
I AM THE BEAUTIFUL NIGHTMARE

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
dark_lord is offline
Reply With Quote
View Public Profile Visit dark_lord's homepage!
 
Old 03-16-2009, 06:51 AM Re: Include Function
Junior Talker

Posts: 4
Name: Chris
Trades: 0
another way to explain it would be

When clicking the links on the navbar i would like the corresponding page to open up in the main section.
claffin is offline
Reply With Quote
View Public Profile
 
Old 03-16-2009, 07:08 AM Re: Include Function
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
That isn't done using includes, for that you would use frames or iframe.

BUT
Don't use frames or iframes to design a site neither should you be using tables for layout
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-16-2009, 07:23 AM Re: Include Function
dark_lord's Avatar
Experienced Talker

Posts: 41
Name: Parijat Roy
Location: INDIA-KOLKATA
Trades: 0
iframes would do but you can do it with javascript(or better AJAX)@claffin!

but these are also against SEO!
You do it for good client side performance, but that may degrade your spider's site accessibility.

If you need high end client side performance, than use it otherwise don't.

i wonder why chrishirst said not to use tables for layout?!
__________________
I AM THE BEAUTIFUL NIGHTMARE

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
dark_lord is offline
Reply With Quote
View Public Profile Visit dark_lord's homepage!
 
Old 03-16-2009, 07:31 AM Re: Include Function
Junior Talker

Posts: 4
Name: Chris
Trades: 0
Ok i have put the following code in

index.php
<head>
<
title>test</title>
</
head>

<
body>
<?
php
$page
= 'main.php'; // Default page
$pages = array('main', 'about','products','gallery','contact');

// Check if p is set
if(isset($_GET['p'])) {

// Check if the page in the url is in the defined array
if(in_array($_GET['p']) $pages) {

$page = $_GET['p'].'.php';

} else {

$page = 'main.php';

}

}
?>

<table border="1" width="100%" height="0">
<tr>
<td height="120" width="100%" colspan="2"><?php include('heading.php');?> </td>
</tr>
<tr>
<td height="0" width="20%"><?php include('leftmenu.php');?> </td>
<td height="0" width="80%"><?php include($page);?> </td>
</tr>
<tr>
<td height="50" width="100%" colspan="2"><?php include('bottom.php');?> </td>
</tr>
</table>

</body>


and in leftmenu.php
<a href="../index.php?p=main">Home</a><p>
<
a href="../index.php?p=about">About Us</a><p>
<
a href="../index.php?p=products">Products</a><p>
<
a href="../index.php?p=gallery">Gallery</a><p>
<
a href="../index.php?p=contact">Contact Us</a><p>


you can see results at
http://handweaving.seitservices.com.au/

Last edited by claffin; 03-16-2009 at 07:41 AM..
claffin is offline
Reply With Quote
View Public Profile
 
Old 03-16-2009, 07:41 AM Re: Include Function
Junior Talker

Posts: 4
Name: Chris
Trades: 0
problem solved thanks
claffin is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Include Function
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.93932 seconds with 12 queries