Jump to content

Archived

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

aviatorisu

IFRAME issue

Recommended Posts

I'm trying to include an IFRAME on my page.  Basically the reason I am using it is to be able to use it as a TARGET for a few links.  I'm able to include it and make it work, but when I go to add PHP code to it, the trouble starts.  I'm wanting the frame to display a default image based on the ID of the page it is included within.  I've done it a few ways, and the best I can figure is that the IFRAME isn't getting the ID data to be able to provide the appropriate variable.  If anyone understands what I am saying, am I correct?  Is there a way around this??

Thanks,

~Z~

Share this post


Link to post
Share on other sites
The code for my default IFRAME page is:

[code]<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0 ALIGN="CENTER" WIDTH="450" HEIGHT="150">
<TR><TD VALIGN="TOP">

<IMG SRC='images/<?php echo "$picture1";?>'>

</TR></TD>
</TABLE>[/code]

The code from the page it is inserted on:

[code]<IFRAME BGCOLOR="#000000" SRC="image.php" MARGINWIDTH=0 MARGINHEIGHT=0 FRAMEBORDER=0 SCROLLING=NO WIDTH=450 HEIGHT=100% NAME="IMAGE"></IFRAME>[/code]

The variable $picture1 is defined on the page where the IFRAME is inserted.

~Z~

Share this post


Link to post
Share on other sites
Put [code]<?php session_start(); ?>[/code] at the top of image.php, then store the variable as a session variable ($_SESSION['picture1']) on the page containing the iframe and call the session variable in image.php. Remember to use session_start() in both pages (before outputting anything).

Share this post


Link to post
Share on other sites
sorry, that reply wasn't for you, it was for designationlocutus.  I'm trying your suggestion now.

I'm a little fuzzy about how to include the session variable ($_SESSION['picture1']) though, could you help with that?

Share this post


Link to post
Share on other sites
Session would be useful if you wanted to maintain the image through several clicks. Start the session the way Daniel suggested (this must be done on every page that you use) and assign your session variable to the picture name.

However to do it the way I suggested, you need to set the iframe src in your second example to produce the correct image.

[code]
SRC="image.php?picture1=image.jpg"
[/code]

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.