Jul 25, 2008

<? Include ?> <iframe/> - This could save me tons of time!

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming
Pages: 1, 2, 3

free web hosting

<? Include ?> <iframe/> - This could save me tons of time!

Joshthegreat
Does anyone know if it is possible to target links into an area using the include tag? Because I don't want to use an iframe.
So I only need one page and all the links would appear where the php include tag is.
This would be super helpfull if anyone could explain if it was possible, and if so how to do it, or if not possible, any alternate codes that would to the same job, excluding the iframe and the regular frame. Thanks.

Reply

no9t9
the include FUNCTION is not an HTML tag and cannot be changed once it is downloaded by the browser. This is because the include function is a SERVER SIDE script meaning it is run by the server and replaced with whatever file you put in the include function. That include function is replaced and the browser (user) never sees the code.

The only way to change the file included in the function is to load another page. You can do this with URL variables.

example: http://yoursite.com/index.php?load=page1.html
http://yoursite/index.php?load=page2.html

in your index.php file you have the code: <?php include($load); "> This will load whatever page you put after the load= in your url. So when you create a link, just use the above url and it will update.

Reply

Joshthegreat
I don't understand at all... maybe what I have at the moment is fine. I just have to change part of the table for all my content pages. No worry though. Thanks for your help.

Reply

beeseven
I'm not sure I entirely understand what you're saying, but what if you made a table or something similar then included the stuff in there?

CODE

<table>
 <tr>
  <td>
   something
  </td>
  <td>
   <?php include 'file.ext'; ?>
  </td>
etc...

Reply

Joshthegreat
I know how to do that. All I'm asking is...
Is it possible to use the include code like an iframe, meaning that you can target files to appear in the place of the include code instead of just one stuck file there. If you know what I mean...

Reply

nancmu
If my understand is right, I suggest you using javascript smile.gif .
The same as "toggle menu"
--> onClick="this.style.display=none" -- for hide your page instantly.
--> onClick="this.style.display='' " -- show your page.

or use function

function toggle_page(page) {
if (page == 1) {
p1.style.display="";
p2.style.display="none";
}
else {
p1.style.display="none";
p2.style.display="";
}
}

<a href=# onClick="toggle_page(1)">show page1</a> | <a href=# onClick="toggle_page(2)">show page2</a>

<div id=p1>
<? include("page1.php");?>
</div>

<div id=p2 style="display: none">
<? include("page2.php");?>
</div>

// something like that.
// and hope, will be right in your mind rolleyes.gif .

 

 

 


Reply

Saint_Michael
i don;t don't know how the coding might go but why dont you use the <div> tags to seperate everything and then create navagation menu from thier that would make sense.

Reply

Joshthegreat
Thanks nancmu, but I just had an idea. Well, not so much of an idea, but a quesiton at least.

is what no9t9 said basically the equvilant (below)? And if it is could someone please tell me how all of that works? Thanks.
http://yoursite.com/index.php?load=page1.html.

Basically what I want is the effect of an iframe, but without using one.

Reply

no9t9
the way i understood your request was that you are trying to use one page something like a template and load the content into an iframe. Except that you don't want to use iframes but instead you want to use the php include function.

so, what I told you to do is exactly that.

basically if you use URLs with variables like this
http://yoursite.com/index.php?load=contentpage.html
you can get the same effect.

in your index.php file you create the template for your site. basically everything that doesn't change on your site, like navigation, backgorund, etc. then you create your content (the stuff that would go in an iframe) in a file called contentpage.html (or whatever you want).

the structure of the index.php file will look something like this.

<banner HTML Code>
<Navigation HTML Code>
<?php include($load); ?>
<footer HTML Code>

now when you want to change the content, you simply change the $load variable.
http://yoursite.com/index.php?load=anothercontentpage.html
so for example if in your navigation you want to link to a CONTACT page, you would use :
<a href="http://yoursite.com/index.php?load=contact.html">Contact</a>

this will not change any of your banner, navigation, footer HTML but will update the CONTENT area with your contact page.

BTW, using javascript for loading page content is not a good idea because some people disable javascript and if they do, your page will be completely useless.
PHP is the way to go.

Reply

Joshthegreat
THANKYOU THANKYOU THANKYOU!!!! Your getting a juicy reputation point for this! Thanks a load man. You need a medal, thanks a bunch, I didn;t really understand what you said before, but I do now. Thanks loads man.

Reply

Latest Entries

Amezis
What I want, is just to get <?php include($load); ?> to work, since I think it's more usefull than <?php include 'file.htm'; ?>, and there will be less files, but for some reasons I can't get it to work!

Reply

hype
Or you can trying integrating all the codes into the files you want to open then lesser error will open... Using the includ codes is very dangerous and may result to pages breakdown...

Reply

karlo
I suggest you try using XMLHttpRequest to make your website unique, as well as making your website load faster, and consumes less bandwidth. The include function in PHP is really useful, but when I comes to uploading your whole website, having seperate files can be a little pain, so if you can, use only 1 PHP file for all of your pages. Or use MySQL to fetch each pages. biggrin.gif

Reply

Amezis
Still can't get it to work. I am using <?php include 'file.htm'; ?> and it works fine, but <?php include($load); ?> won't work, when I enter loadpage.php?load=testpage.htm (that's what I called it). Do it really have to be INDEX.php or is LOADPAGE.php allowed too? Where the testpage.htm should load, there's nothing...

Reply

no9t9
QUOTE
Well, easy, easy code, but I know I have forgot something. what?
In the same folder, I have "contentpage.html". Trying to load index.php?load=contentpage.html don't work.
Hehe as I said, I don't know anything about php, just trying it now tongue.gif
*



the code looks right to me. what is your website and what is the problem? any error messages? is your file named index.php? are there other index files in the same directory? delete index.htm or index.html because they will get loaded before index.php (or you can rename them). Post your site so it will be easier to diagnose the problem.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Pages: 1, 2, 3
Recent Queries:-
  1. php include with iframe - 50.49 hr back. (3)
  2. include php in iframe - 51.37 hr back. (1)
  3. include page iframe - 114.35 hr back. (1)
  4. php include like iframe in html - 125.06 hr back. (1)
  5. iframe verso include php - 151.83 hr back. (2)
  6. php include instead of iframe - 166.92 hr back. (1)
  7. include("