displaying a php file inside a div.

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
jwaqa1
Forum Newbie
Posts: 2
Joined: Mon Sep 24, 2007 2:17 am

displaying a php file inside a div.

Post by jwaqa1 »

Hello everyone.
I have a slight problem. I am about 3 months new to php coding and am requesting an answer to the following.
Bascially i have php link that should display a php file within a div.

2 php files are being used. one as the index the other as the file to be loaded into the div i created.

This is the php code - index.php. this code is inside php start and finish conditions.
<a href=view_subCat.php?cat_Id=$cat_Id target= content><font size='2' color='#0066FF'>"."$cat_Name"."</font></a>

This is the div where the view_subCat.php file need to be loaded - index.php - this code does not exist inside php start and close conditions
<div id="content" style="position:absolute; top:50; left:0; width:200; height:648; z-index:1; border: #000000 1px solid;background-color:none;"></div>

At the moment it is loading the view_subCat.php file in full view rather then inside the div i created. The div has an id called content that i use as a target. I have also tried
rel. However, after using either rel or target, the file loads the php in a new window or loads the file in full view of the index page where the div is coded.

Is there anything i can do to make sure it loads within the div's only?
phpsir
Forum Newbie
Posts: 1
Joined: Mon Sep 24, 2007 2:51 am

you need ajax support ,or div contain iframe

Post by phpsir »

you need ajax support ,or div contain iframe

contract me 733905@gmail.com
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Post by aceconcepts »

Not sure if this is what you are after but take a look: http://www.dynamicdrive.com/dynamicinde ... viewer.htm
lnt
Forum Newbie
Posts: 12
Joined: Mon Sep 24, 2007 8:47 am

Re: displaying a php file inside a div.

Post by lnt »

jwaqa1 wrote:Hello everyone.
<a href=view_subCat.php?cat_Id=$cat_Id target= content><font size='2' color='#0066FF'>"."$cat_Name"."</font></a>
The attribute "target" of anchor element must be the name of some window.
In your case, use Ajax to get information from server and use DOM to fill div block
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Make sure this works without Javascript enabled too, if you go the Ajax route.
lafflin
Forum Contributor
Posts: 123
Joined: Thu Jul 26, 2007 6:26 pm

Post by lafflin »

Why Ajax? could you not use the <iframe> tag to display the content that you want in your <div>? The only reason that you would want to use Ajax is if the content within your <div> needed to be updated continuosly without refreshing the page. But then I could be missing something, I dunno.
lnt
Forum Newbie
Posts: 12
Joined: Mon Sep 24, 2007 8:47 am

Post by lnt »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


If you don't like Ajax, use iframe
[syntax="html"]<a href="javascript:document.getElementById('content').src='view_subCat.php?cat_Id=$cat_Id'"><font size='2' color='#0066FF'>"."$cat_Name"."</font></a>

<iframe id="content" style="position:absolute; top:50; left:0; width:200; height:648;border: #000000 1px solid;background-color:none;"></iframe> 
Try replace iframe with div ? It's OK?


feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
mrkite
Forum Contributor
Posts: 104
Joined: Tue Sep 11, 2007 4:19 am

Post by mrkite »

lnt wrote:If you don't like Ajax, use iframe

Code: Select all

<a href="javascript:document.getElementById('content').src='view_subCat.php?cat_Id=$cat_Id'"><font size='2' color='#0066FF'>"."$cat_Name"."</font></a>

<iframe id="content" style="position:absolute; top:50; left:0; width:200; height:648;border: #000000 1px solid;background-color:none;"></iframe>
Try replace iframe with div ? It's OK?
For an iframe, instead of "id" you need to use "name" to reference it as a target.

So if you're going to use the above javascript with getElementById() keep it id="content" but if you want to use your original code of target="content" you need to make it name="content".
jwaqa1
Forum Newbie
Posts: 2
Joined: Mon Sep 24, 2007 2:17 am

Thankyou

Post by jwaqa1 »

Its working fine now Thankyou.

I modified my html file to use iframes.
Bascially i modified and used code from the http://www.dynamicdrive.com/dynamicinde ... viewer.htm example.

the following php code tells the javascript tabs to load the php files into the iframes.

<ul id="tablist"> print("<li><font color='#0066FF'><a class='current' href=view_subCat.php?cat_Id=$cat_Id onClick='return handlelink(this)'>"."$cat_Name"."</a></font></li>");</ul>

The Pages are loaded into the following iframe
<iframe id="tabiframe" src="sub Categories.htm" width="10%" height="80%"></iframe>

regards jwaqa1
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Post by aceconcepts »

Pretty nice script eh
Post Reply