TinyPortal

Development => Resources => Topic started by: Cyberion on November 09, 2007, 04:39:43 PM

Title: How to display msg in iframe
Post by: Cyberion on November 09, 2007, 04:39:43 PM
Hello there guys.

I'm trying to display a message on my forum in the artcle using the iframe tag. However my entire forum is displayed.

Is there a way to solve this?

Here is an example of what i'm talking about

<iframe width="100%" scrolling="yes" height="600" frameborder="0" marginheight="0" marginwidth="0" src="http://www.cyberionsystems.com/exoclan/index.php?topic=1264.msg21365#msg21365"></iframe>

All i need is to display message 21365 instead of all those blocks, images, etc... I need entire text of this message to be displayed. Nothing else. No author, no replies. How can I do this? Badly in need of help as I have no idea how to do this. I rarely ask for help, but here i'm stuck.
Title: Re: How to display msg in iframe
Post by: Dragooon on November 09, 2007, 04:59:36 PM
You cannot use iFrame here. You will be needing PHP to do this.
Something like,

global $db_prefix;
$query = db_query("SELECT ID_MSG, body
                             FROM {$db_prefix}messages
                             WHERE ID_MSG = 21365
                             LIMIT 1",__FILE__, __LINE__) or die(mysql_error());
$body = array();
while ($row = mysql_fetch_assoc($query)) {
        $body[] = array(
          'msg' => $row['body'],
        );
}
mysql_free_result($query);
foreach($body as $b)
{
echo $b;
}

This is a untested code I just wrote while replying to this post
Title: Re: How to display msg in iframe
Post by: Cyberion on November 09, 2007, 05:27:42 PM
hmmm thx for the help bro, but it doesn't work. I switched to PHP article, pasted your code in there

and here what it gives - http://www.cyberionsystems.com/exoclan/index.php?page=19


It jsut writes "array" that's it. Any ideas?
Title: Re: How to display msg in iframe
Post by: bloc on November 09, 2007, 09:09:21 PM
Try instead of "echo $b;" to use "echo $b['msg'];"
Title: Re: How to display msg in iframe
Post by: Cyberion on November 09, 2007, 09:45:46 PM
thx Bloc, it works, however it displays the text with all formating. So it kinda ignores any bbcode tags and displays the text and thos tags from the message.

Any ideas to this problem?

Sorry for being such a noob, but i'm really bad at php coding, i'm trying to figure out something, but this is over my skills ;)

You can see what I mean by following the link again - http://www.cyberionsystems.com/exoclan/index.php?page=19
Title: Re: How to display msg in iframe
Post by: bloc on November 09, 2007, 11:21:03 PM
ah, i forgot..of course you need to convert it too. Use

echo doUBBC($b['msg']);

and all bbc codes should display correctly.
Title: Re: How to display msg in iframe
Post by: Cyberion on November 10, 2007, 07:54:18 AM
thx Bloc, it now works perfectly.

Here is the final compilation for those that might be interested in such feature (the following code is created by Dragooon and fixed by Bloc):

For displaying a certain message from your forum in the PHP article, change the line "WHERE ID_MSG = 21365" to a number related to your message.
global $db_prefix;
$query = db_query("SELECT ID_MSG, body
                             FROM {$db_prefix}messages
                             WHERE ID_MSG = 21365
                             LIMIT 1",__FILE__, __LINE__) or die(mysql_error());
$body = array();
while ($row = mysql_fetch_assoc($query)) {
        $body[] = array(
          'msg' => $row['body'],
        );
}
mysql_free_result($query);
foreach($body as $b)
{
echo doUBBC($b['msg']);
}
Title: Re: How to display msg in iframe
Post by: Dragooon on November 11, 2007, 04:42:55 AM
Thanks Bloc :)
This is what happens when I write my code at 2 AM :P