View Full Version : Include page help

07-13-2005, 10:05 AM
I am developing site :o where i need to call external file. I have 100 pages to make, in all pages left bar and right bar is the same, but it can be change later on. I know we can make 2 differant files and can call it in main file, i tried to use jsp, but i dont know some how its not showing any of external file. :( Please help me and tell me which is the best way to call external file. and code for it.

its urgent.

Sudhir :o

07-13-2005, 10:47 AM
This depends on the format for your pages.
Personally, I generate links using mysql for pages that can be dynamic, depending on the backend for the site. If its smaller, I validate using arrays. For larger number of pages such as yours, you would probably want to go with the inclusion you are suggesting.
Now, I'm just not certain what your structure is like, and how your generating information from it.
Is what you are looking for, being able to build each link by selecting the names from the filesystem? Or do you have a specific file/method in which you contain these file names? Let us know how you have/plan on getting the names for the pages in the first place, that will tell us what method to look at doing.

Bill Posters
07-13-2005, 10:49 AM
Some info about PHP Includes…

PHP online manual: include() function (http://uk2.php.net/manual/en/function.include.php)
W3Schools.com : PHP Include Files (SSI) (http://www.w3schools.com/php/php_includes.asp)
Including Content - A Review
Part III - Creating Templates with Include Pages (http://www.outfront.net/tutorials_02/getting_started/includes3.htm)
Google : php includes introduction (http://www.google.com/search?hl=en&lr=lang_en&ie=UTF-8&safe=off&c2coff=1&q=php+includes+introduction&btnG=Search)

(PHP Includes aren't complex and are easy to implement. The above links all say roughly the same thing, but one will have a voice that suits you best and helps you get to grips with the basics.)

07-13-2005, 11:18 AM
Hi Thanks for your reply. here is the code which i am using for my files.

index.php file where i want to call external file.

<%@ page contentType="text/html; charset=" language="java" import="java.sql.*" errorPage="" %>
<jsp:useBean id="db" scope="page" class="mysql.Connect" />

<title>Association of Medical Technologists (WI)</title>

<!-- Metadata generated by http://www.mahatma.org.in -->

<body bgcolor="#FFFFFF" vlink="#000000" link="#000000 text="#000000" topmargin=1 leftmargin=1 marginheight=1 marginwidth=1>

<table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
<tr><td valign="top" align="left"><jsp:include page="topbar.jsp" flush="true" /></td></tr>
<td height="411" align="left" valign="top">
<table border=0 cellpadding=0 cellspacing=2>
<td width="159" valign=top>
<%@ include page="leftbar.jsp"%></td>
<td width="570" valign=top>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
there is more code. but i think from this you can understand, what i am looking for.

and this is leftbar.jsp file which i want to include in index.php

<table border="0" width="100%" cellspacing="0" cellpadding="0">
<th width="100%" align="left" valign="top" bgcolor="#23397F"><p align="center"><strong><font color="#FFFF00" size="2" face="Verdana, Arial, Helvetica, sans-serif">e-Books<br>
</font></strong><img src="images/left-bttn-bar4.gif" width="159"><br>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="160" height="130">
<param name="movie" value="images/slide.swf">
<param name="quality" value="high">
<embed src="images/slide.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="160" height="130"></embed></object>

Please see this and let me know whats wrong in it. or i should php for it? But i dont know how to include files in php. Please guide me.


07-13-2005, 02:08 PM
hey guys/ gals,

i am waiting for reply. pls help me in it.

sudhir :(

07-13-2005, 02:38 PM
Did you even read those links posted for you? .php includes are the best way to do this.

07-13-2005, 04:28 PM

<%@ include page="leftbar.jsp"%>


<?php include('./leftbar.jsp');?>

Or with ASP style identifiers:

<% include('./leftbar.jsp');%>

Please note, I wouldn't recommend using those, as they may be off on a using server. As well, you cannot combine ASP and PHP together within one script, it will be processed as one or the other.
I had been mistaken as well as to what you mean, I thought you were asking how to create the links using php, not how to include them.

Another option as well is a virtual() function, though with your ASP, I'm going to say your virtual() function will not work.

07-14-2005, 12:57 PM
I'll tell you know what i need exactly. I have to develope site of 100 pages, on each page i have common content that is on left side, which i am calling as leftbar. now what i want i want to make 1 file call leftbar which will include in all pages dynamicaly. So if there is any changes in leftbari will have to change only leftbar so it will be automatically change in all pages.

Now you tell me what should i use as i will upload it on linux server. I cant use asp. php and jsp i can use but i dont know how it will work, as in jsp i tried adding this line of code
<jsp:include page="leftbar.jsp" flush="true">
But i dont know why its not showing.

Please help.


07-14-2005, 04:55 PM
Unfortunatly, I'm not familiar with jsp or how it works, so I can't give you any advice there. However, if you mean the page is a jsp page, don't be concerned, you can include that as it should be parsed ahead of time (jsp is server side right, lol).
Using a *nix server leaves you quite a few opportunities to use. Apache can use SSI, which, now its been awhile here, but I think its called like so:

<#-- include_virtual('file.shtml') -->

Or something similar.
Php uses include as a function:


Or, you can use virtual() if you are running on an apache system, which is the same as running an SSI but using php instead for the processor.
I'm stuck though, I'm not sure what you are looking for. I've suggested the include() for you, and Bill Posters set out a set of links for you to view. So if these don't help you, I'm sorry but I'm at a loss for what your looking for...