Jump to content

IFRAME issue


aviatorisu

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~
Link to comment
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~
Link to comment
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).
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.