Jump to content

Appending iframe vars


ParadoxKing

Recommended Posts

Hello, lets get straight into it. I have a web comic viewing script, it worked perfectly well, but it only preformed a simple task: display comics dynamically and allow viewers to scroll through comic (appending variables to the url). All this was displayed on the index page. I thought that was all fine and dandy until I decided that I wanted to have an archive page. So I integrated the script into a mySQL database. After a few tries I got it working fine (save for some problems I will mention in another thread). The pages are:

 

Archive

Comic Page

 

And here are the codes

 

<?php 
$user="root";
$password="m99r9K6";
$database="anicom";
mysql_connect("127.0.0.1",$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM imgcont";
$result=mysql_query($query);
while ($row=mysql_fetch_array($result)) {
	print "<li><span class='php'><a href='comic.php?id={$row["id"]}' target='comix'>{$row["title"]}</a></span></li>";
}
?>

 

<?php 
$user="root";
$password="m99r9K6";
$database="anicom";
mysql_connect("127.0.0.1",$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM imgcont WHERE id='$id'";
$result=mysql_query($query);
while ($row = mysql_fetch_array($result))  {
	$maximages=2;
	echo sprintf("<img src='comic{$row["id"]}.png' /> \n");
	echo sprintf("<a href=\"comic.php?id=%d\">\n<img border=\"0\" src=\"back.png\" alt=\"Previous Comic\" align=\"left\" />\n</a> \n",(($row['id']-1>0)?(--$row['id'])$row['id'])));
	echo sprintf("<a href=\"comic.php?id=%d\">\n<img border=\"0\" src=\"next.png\" align=\"right\" alt=\"Next Comic\" />\n</a> \n",(($row['id']+1<=$maximages)?(++$row['id'])$row['id'])));
}	
?>

 

So, that works fine. But then I got complaints about moving the comics off the index page. So I decided that I would use <iframe></iframe> tags and put archive and comic pages on the index page through that.

Here is the page:

Club Index

 

And the very very basic code:

 

<iframe name="comix" src="archive.php" frameborder="0" class="fr" allowtransparency="true"/>

 

Unfortunately that defeated half the functionality of the original script, I the comic id was not displayed in  the url anymore as it was on a different page. Here is my question: How do I append the id var in the iframe to the index page url?

Link to comment
Share on other sites

the page that the iframe targets is by all rights, a seperate and unique page and therefore doesn't access the same namespace as the parent.  In your iframe tag, when you target the framed page, target it with $_GET args .... thats the only way.  Depending on how your site works, this might not work for you.

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.