include() at the very bottom

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
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

include() at the very bottom

Post by Steveo31 »

How would I go about getting a page with include to appear at the very bottom of the page it is include() in? Tables, or is there an easier way?
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

i dont quite understand your question, but i think your asking is there a way to include like a footer at the bottom of your page? Well, yes, jsut use include(). You can use Include() any where on your PHP page and it will include that file!
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

Yep. Got that far :)

I guess what I am asking more specifically is to have the contents of that footer.php to be at the bottom of the page it is included in. Maybe have a table at the absolute very bottom of the page, and include() it there.

-S
AbelaJohnB
Forum Newbie
Posts: 9
Joined: Sat Feb 28, 2004 12:14 am

Post by AbelaJohnB »

So, I'm guessing your just wanting to know how to include a "footer" file on every page of your website, right (??)

If so, here's how.

You've got two (or a bazillion) files:

File One: index.php

Code: Select all

<HTML>
<HEAD>
<TITLE> index.php </TITLE>
</HEAD>
<BODY>

This is our main file.

<BR /><BR />
<?php
///////////////////////////////////////////////////////
// INCLUDE FOOTER FILE
///////////////////////////////////////////////////////
include_once("/path/to_my/footer.php");
//
?>
That's your main file, or any other file on your website. Just make sure those last seven (7) lines of code are at the very bottom of ever page (or before </BODY></HTML> depending on how you care to do it.


Than for our global "footer" file, you simply create a second file. We'll call it: footer.php

Code: Select all

Copyright &amp;copy; Your Name. 2000-&lt;?= date('Y');?&gt; All Rights Reserved.

&lt;/BODY&gt;
&lt;/HTML&gt;

And that's all it really takes.

You'll notice I use [php_man]include_once()[/php_man] and not [php_man]include()[/php_man] because you only want your footer file to load once on any given php file.


And, if this is totally not what you want.... well, I tried. ;)
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

Hah... no, but thanks. I have the footer being included no problem. What I am asking is how to position the contents of that page at the bottom of the page it is called into.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Put it @ the bottom of your code....

Show us what you got so far...
User avatar
Pointybeard
Forum Commoner
Posts: 71
Joined: Wed Sep 03, 2003 7:23 pm
Location: Brisbane, AUS
Contact:

Post by Pointybeard »

You mean at the absolute bottom of the page? You can do that sort of thing with CSS heres a link that might help you. AListApart - Exploring Footers Hope that helps

-PB
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

Just playin around with stuff... getting vars and stuff down, so don't laugh ;)

Code: Select all

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<?php
#
#--------- Form deleted for space
#
if(!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['comments'])){
	$name=$_POST['name'];
	$address=$_POST['email'];
	$comments=$_POST['comments'];
	echo ("<table width="100%" cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td width="5%"><div align="center">
			<td width="50%"  bgcolor='#EFEFEF'>
				<i>This is the information you submitted:</i><br><br>
    	    	Name:  $name<br>
       	 		Email:  <a href='mailto:$address'>$address</a><br>
       			Comments:  $comments<br><br>
				<div align='center'><font size="1">If you would like to see the entire guestbook, click <a href='guestbook.php'>here</a>.</div>
			</td>
				<td width="25%">
				&nbsp;
				</td>
				
			</div>
		</td>
	</tr>
</table>");
}else{
    echo "<table width="100%" cellpadding="0" cellspacing="0">
    <tr>
        <td>
			<div align="center">
        Fill it out man.
			</div>
        </td>
    </tr>
</table>
";
}



include("footer.php");
#
#-- Getting this at the absolute bottom of the page, regardless of browser size, is what I am after.  Right now it is at the bottom of the form.
#

?>
</body>
</html>
-S
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

<?php
<html> 
<head> 
<title>Untitled Document</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
</head> 

<body> 

<?php 
# 
#--------- Form deleted for space 
# 
if(!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['comments'])){ 
   $name=$_POST['name']; 
   $address=$_POST['email']; 
   $comments=$_POST['comments']; 
   echo ("<table width="100%" cellpadding="0" cellspacing="0" border="0"> 
   <tr> 
      <td width="5%"><div align="center"> 
         <td width="50%"  bgcolor='#EFEFEF'> 
            <i>This is the information you submitted:</i><br><br> 
              Name:  $name<br> 
                 Email:  <a href='mailto:$address'>$address</a><br> 
                Comments:  $comments<br><br> 
            <div align='center'><font size="1">If you would like to see the entire guestbook, click <a href='guestbook.php'>here</a>.</div> 
         </td> 
            <td width="25%"> 
              
            </td> 
             
         </div> 
      </td> 
   </tr> 
</table>"); 
}else{ 
    echo "<table width="100%" cellpadding="0" cellspacing="0"> 
    <tr> 
        <td> 
         <div align="center"> 
        Fill it out man. 
         </div> 
        </td> 
    </tr> 
</table> 
"; 
} 
<table height=100%>
<tr><td></td></tr>
</table>


include("footer.php"); 
# 
#-- Getting this at the absolute bottom of the page, regardless of browser size, is what I am after.  Right now it is at the bottom of the form. 
# 

?> 

This should do the trick
</body> 
</html> 
?>
User avatar
Pointybeard
Forum Commoner
Posts: 71
Joined: Wed Sep 03, 2003 7:23 pm
Location: Brisbane, AUS
Contact:

Post by Pointybeard »

*cries at the use of a table for page formatting*

Steveo31, start good practises now and use XHTML and CSS. :)
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

TY Phenom... I'll give it a try.


PB- Thanks for the tears, and the links. This is the way I learned, I guess there is an easier way. :)
Post Reply