Jump to content

Dynamic iframe and php


swamp

Recommended Posts

Hello all,

 

I've got this script working on my site that retrieves and displays the last 5 forum posts from my phpBB database.

 

It is all working fine, and the links re-direct to the forum properly.

 

On another page I have my forum inside an iframe to keep the main header of the website. That all works fine too.

 

I was wondering, however, how would I make the php generated links open in the iframe of this page instead of in the parent window?

 

I was thinking java may well work, but I'm not too sure how to go about integrating this into the php script.

 

Here is my php code for getposts.php:

 

 

//retrieve posts from database
$a = mysql_query("SELECT * FROM $table7 ORDER BY post_time DESC LIMIT $postlimit ")or die (mysql_error());
while ($row = mysql_fetch_array($a)) {
$pid = $row['poster_id'];
$psid = $row['post_id'];
$time = $row['post_time'];
$postids = $row['forum_id'];

//Get User Name From Database For Posts
$b1 = "SELECT username AS name FROM $table6 WHERE user_id=$pid";
$b = mysql_query($b1)or die(mysql_error());
while ($row1 = mysql_fetch_array($b)) {
$name = $row1['name'];

//Get Post Info
$c1 = "SELECT post_subject AS subject FROM $table8 WHERE post_id=$psid";
$c = mysql_query($c1)or die(mysql_error());
while ($row3 = mysql_fetch_array($c)) {
$subject = $row3['subject'];

//Get Catergory & forum name
$d1 = "SELECT cat_id AS cat_id, forum_name AS fname FROM $table10 WHERE forum_id=$postids";
$d = mysql_query($d1)or die(mysql_error());
while ($row4 = mysql_fetch_array($d)) {
$catid = $row4['cat_id'];
$forum = $row4['fname'];

//Get Cat Name
$e1 = "SELECT cat_title AS cattitle FROM $table9 WHERE cat_id=$catid";
$e = mysql_query($e1)or die(mysql_error());
while ($row5 = mysql_fetch_array($e)) {
$category = $row5['cattitle'];

$current_timestamp = "$time"; 
$date = date('Y-m-d h:i:s', $current_timestamp); 


echo "

<strong>  <a href=\"$webaddress/viewtopic.php?t=$psid\">$subject</a>  </strong>

<br>


In <a href=\"$webaddress/viewforum.php?f=$postids\">$forum</a> 

by <a href=\"$webaddress/profile.php?mode=viewprofile&u=$pid\">$name</a>

<p>



";

}}}}}

?>

 

Any help would be more than appreciated!

 

Thanks a lot,

 

swamp.

Link to comment
https://forums.phpfreaks.com/topic/97949-dynamic-iframe-and-php/
Share on other sites

Yeah, I did try that - but how do you get it to link into a new page with the iframe?

 

I've got these pages:

 

index.php - the homepage with getposts.php included using php

 

getposts.php - the page with the php code to show last 5 forum posts

 

forumdisplay.php - the page with the iframe

 

I need to be able to click on the links from index.php and it load the relative page in the iframe on forumdisplay.php

 

Cheers,

 

Kieran

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.