Jump to content

Archived

This topic is now archived and is closed to further replies.

lilywong

How to put IFRAME into php file

Recommended Posts

I have a switch case like follow, and i want to put the iframe like[b] (<iframe width=400 height=280 src ="default.php"></iframe>) [/b]inside the include, is there any way to do this ?
i do not want to limit the src link to default.pgp, i want it to goes with what i have selected from the switch case, is there any way to do this ?

<?php

switch(acGet("sec"))
{
case "ad_manage_user" : include_once("../admin/manage_user.php"); break;
case "ad_manage_folder" : include_once("../admin/manage_folder.php"); break;
case "ad_assign_folder" : include_once("../admin/assign_folder.php"); break;
}

?>

thanks

Share this post


Link to post
Share on other sites
why dont you just dump the variable into the IFrame instead?

something like this.....


[code]
#By no means this code is supposed to work, its just to give you an idea.
function writeIFrame($theFrame){
echo ("<iframe width=400 height=280 src ='$theFrame'></iframe>");
};

writeIFrame($acGet);[/code]

Share this post


Link to post
Share on other sites
sorry i am newbie, can't understand the code, do you mind to give details explanations and example in regards to my problem? thanks

Share this post


Link to post
Share on other sites
Ok, maybe I missunderstood what you are trying to acomplish, but for what I saw on your code you are trying to add content to an IFrame depending on the variable you are receiving, and the way you are handling this is through a CASE statement.

Well, what I was suggesting was to write down a function that receives the path of the file you want to load to the IFrame. that will save you extra steps.

Here is an example that I slapped together:

[code]Enter the page you want to load into the Iframe
#this is just a sample form to show you how to pass the file path variable
<form method="get" action=''>
<input type='text' name='loadToIFrame'></input>
<input type='submit' value='submit'/>
</form>
<br />
<?
#simple if statement to check if we have declared the variable, if we havent declared a variable then a default page gets loaded to avoid ugly 404 errors.
if (!$loadToIFrame){
$loadToIFrame = 'www.google.com';
}else{
$loadToIFrame = $_GET['loadToIFrame'];
}
echo 'iframe to load= '.$loadToIFrame.'<br /><br />';
?>

<--! This is where we actually load the frame -->
<iframe width=600 height=280 src='<? echo 'http://'.$loadToIFrame; ?>'></iframe>[/code]


click here to see it in action:
[a href=\"http://www.helmutgranda.com/php/phpiframe/\" target=\"_blank\"]http://www.helmutgranda.com/php/phpiframe/[/a]


I hope that helps!

Share this post


Link to post
Share on other sites
hmm..... i do not want to key in data into text field.

in this case, there are three buttons, (Manage User, Manage Folder, Assign Folder),
for eg, when i click Manage User button, the main page will include the (case "ad_manage_user" : include_once("../admin/manage_user.php") automatically. any idea ?

thank you so much !!

Share this post


Link to post
Share on other sites
Well, you dont HAVE TO use the text field, it was just a sample of how you could get things to work. I created a new small script that does similar to what you are asking (at least I think so) :)

[code]<script language='javascript'>
function getNewPage(thePage){
open ('index.php?loadToIFrame='+thePage, '_self');
}
</script>

<input type='button' onclick="getNewPage('www.google.com'); return false" value='google'>&nbsp;<input type='button' onclick="getNewPage('www.amazon.com'); return false" value='amazon'>&nbsp;<input onclick="getNewPage('www.helmutgranda.com'); return false" type='button' value='helmut'>
<br />
<?
#simple if statement to check if we have declared the variable, if we havent declared a variable then a default page gets loaded to avoid ugly 404 errors.
$loadToIFrame = $_GET['loadToIFrame'];

if (!$loadToIFrame){
$loadToIFrame = 'www.google.com';
}else{
$loadToIFrame = $_GET['loadToIFrame'];
}
echo 'iframe to load= '.$loadToIFrame.'<br /><br />';
?>

<!-- This is where we actually load the frame -->
<iframe width=600 height=280 src='<? echo 'http://'.$loadToIFrame; ?>' name='holder'></iframe>[/code]

Working Sample:

[a href=\"http://www.helmutgranda.com/php/phpiframe2/\" target=\"_blank\"]http://www.helmutgranda.com/php/phpiframe2/[/a]

Share this post


Link to post
Share on other sites
hi yah, sorry for trobling you so much, what i mean is, i want to include the a file into the main page (main.php), not to change the whole page which i click the button.

For example, the main page maybe like below:

[b]buttonA buttonB buttonC buttonD[/b] ---> Header(put in main.php)

=============================

contents area are here, and the iframe also
put here

-------> contents area, show include file
for eg, if buttonA is clicked, should
include file like
include_once("../admin/A.php")



=============================
copyright @ 123 company, 2003 -------------> Footer (put in main.php)


buttonA link to A.php, buttonB link to B.php,
buttonC link to C.php, buttonD link to D.php.
so, when i click buttonA, the contens area should only display A.php,
which only have include_once("../admin/A.php"), this because the A.php need to take variable from the main.php as well, so must use include in this way, do you get what i mean ?

Thank you so much


Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.