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
https://forums.phpfreaks.com/topic/81830-appending-iframe-vars/
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
https://forums.phpfreaks.com/topic/81830-appending-iframe-vars/#findComment-415743
Share on other sites

Archived

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

×
×
  • 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.