Home
>
Outdated forums
>
Phorum 3 forums (READ ONLY)
>
Finished Mods and Plug-ins (READ ONLY)
>
Topic
Hack to display last posts in another document
Posted by Rene
Rene
Hack to display last posts in another document February 27, 2001 03:17AM |
The attached index.php will list the last 5 postings in forum number one..
I included this in index.php on my home page. It works just fine..
Modify it to fit your system..
There are a few comments in the attached file.
It's basically just a modified version of the quicklist script included with phorum.
Biggest difference is that it doesn't need an argument to be passed on to the php script.. It's included in the file.
If you wish to see it, it's on my front page. The site is in danish. (it's not an error ;)
[kraftwerk.adsl.dk]
Best regards..
Renˆ
I included this in index.php on my home page. It works just fine..
Modify it to fit your system..
There are a few comments in the attached file.
It's basically just a modified version of the quicklist script included with phorum.
Biggest difference is that it doesn't need an argument to be passed on to the php script.. It's included in the file.
If you wish to see it, it's on my front page. The site is in danish. (it's not an error ;)
[kraftwerk.adsl.dk]
Best regards..
Renˆ
Guy
Re: Hack to display last posts in another document March 08, 2001 02:03PM |
Rene
Re: Hack to display last posts in another document March 13, 2001 02:54PM |
This is two scripts.
One for showing the 5 headlines
One for showing the last 5 text bodies (without carrige return)
Best regards
Rene
<?
//This script will show the last 5 posted headlines in forum number 1
$f=1;
chdir("../phorum/");
include "common.php";
$number=5; // number of messages to show.
$SQL="select id, thread, author, subject, datestamp from $ForumTableName order by datestamp desc limit $number";
$q->query($DB, $SQL);
$rec=$q->getrow();
while(is_array($rec)){
echo "$rec[author] -<a href=\"$forum_url/$read_page.$ext?f=$num&i=$rec[id]&t=$rec[thread]\"> $rec[subject] </a>- $rec[datestamp]<br>\n";
$rec=$q->getrow();
}
?>
<?
// this will show the last five posts in forum number 1.
// this will NOT do carrige returns, so the body text is returned as one line.
// I don't know what to do about it.
$f=1; // the forum number, as I only have one forum, I use number one
chdir("../phorum/"); // change this to fit your system
include "common.php";
$number=5; // number of messages to show.
$SQL="select id, body from $ForumTableName"."_bodies order by id desc limit $number";
$q->query($DB, $SQL);
$rec=$q->getrow();
while(is_array($rec)){
echo " $rec[body]<br>\n";
$rec=$q->getrow();
}
?>
Re: Hack to display last posts in another document March 27, 2001 10:52PM |
Jules
Re: Hack to display last posts in another document March 30, 2001 10:27PM |
Rene
Re: Hack to display last posts in another document April 18, 2001 12:59AM |
Clickable header? Aren't they linking to the particular message?
The line below is the output you see in your browser.
You can modify that as much as you want.
"$rec[author]" prints the name of the author who wrote the message.
It might look complex but it actually quite simple.
You can see the html codes in the line.
----- this line prints the html document ----
echo "$rec[author] -<a href=\"$forum_url/$read_page.$ext?f=$num&i=$rec[id]&t=$rec[thread]\"> $rec[subject] </a>- $rec[datestamp]<br>\n";
Best regards
René "rene AT kraftwerk.adsl.dk" (replace AT with @)
BTW: you can see this working on my site.
[kraftwerk.adsl.dk]
It's in danish so very few of you will be able to understand the site, but you can see the links on the main page. And you can click them to go to the message itself.
The line below is the output you see in your browser.
You can modify that as much as you want.
"$rec[author]" prints the name of the author who wrote the message.
It might look complex but it actually quite simple.
You can see the html codes in the line.
----- this line prints the html document ----
echo "$rec[author] -<a href=\"$forum_url/$read_page.$ext?f=$num&i=$rec[id]&t=$rec[thread]\"> $rec[subject] </a>- $rec[datestamp]<br>\n";
Best regards
René "rene AT kraftwerk.adsl.dk" (replace AT with @)
BTW: you can see this working on my site.
[kraftwerk.adsl.dk]
It's in danish so very few of you will be able to understand the site, but you can see the links on the main page. And you can click them to go to the message itself.
Re: Hack to display last posts in another document May 01, 2001 11:10AM |
I just can't get this to work.
It'll be at [www.excellencethroughexercise.com]
The code I am using is:
<?
//This script will show the last 5 posted headlines in forum number 1
$f=1;
chdir("forum/");
include "common.php";
$number=5; // number of messages to show.
$SQL="select id, thread, author, subject, datestamp from $ForumTableName order by datestamp desc limit $number";
$q->query($DB, $SQL);
$rec=$q->getrow();
while(is_array($rec)){
echo "$rec[author] -<a href=\"$forum_url/$read_page.$ext?f=$num&i=$rec[id]&t=$rec[thread]\"> $rec[subject] </a>- $rec[datestamp]<br>\n";
$rec=$q->getrow();
}
?>
I tried getting rid of the $f=1; because I have about 50 forums, but that didn't work either. I just keep getting absolutely no html output. A blank page. No errors, which is good, but blank.
Any suggestions would be greatly appreciated!
Mick
It'll be at [www.excellencethroughexercise.com]
The code I am using is:
<?
//This script will show the last 5 posted headlines in forum number 1
$f=1;
chdir("forum/");
include "common.php";
$number=5; // number of messages to show.
$SQL="select id, thread, author, subject, datestamp from $ForumTableName order by datestamp desc limit $number";
$q->query($DB, $SQL);
$rec=$q->getrow();
while(is_array($rec)){
echo "$rec[author] -<a href=\"$forum_url/$read_page.$ext?f=$num&i=$rec[id]&t=$rec[thread]\"> $rec[subject] </a>- $rec[datestamp]<br>\n";
$rec=$q->getrow();
}
?>
I tried getting rid of the $f=1; because I have about 50 forums, but that didn't work either. I just keep getting absolutely no html output. A blank page. No errors, which is good, but blank.
Any suggestions would be greatly appreciated!
Mick
Jules
last post including msg body... May 08, 2001 03:30PM |
Hi,
im trying to display on a separate page the headers plus the msg body of the 3 last messages of a certain forum...but i cant seem to get it to work since its 2 diferent tables...im having problems making the queries work with the while loop...any help would be appreciated =) thx
Jules
im trying to display on a separate page the headers plus the msg body of the 3 last messages of a certain forum...but i cant seem to get it to work since its 2 diferent tables...im having problems making the queries work with the while loop...any help would be appreciated =) thx
Jules
Re: last post including msg body... May 08, 2001 07:53PM |
Jules
Re: last post including msg body... May 09, 2001 03:40AM |
ya, tried something similar... i used your example, well, atleast now i dont get parse errors, but i also dont see anything hehe
here is what i did:
$f=8;
chdir("./forums");
require "common.php";
$number=3;
$ssSQL = "SELECT id, subject, author, host, datestamp, body FROM $ForumTableName, $ForumTableName"."_bodies WHERE $ForumTableName.id=$ForumTableName"."_bodies.id AND approved='Y' ORDER BY datestamp DESC LIMIT $number";
$q->query($DB, $ssSQL);
$res=$q->getrow();
while(is_array($res)) {
$date = $res["datestamp"];
$host = $res["host"];
$subject = $res["subject"];
$author = $res["author"];
$body = $rec["body"];
// html part
echo "$datestamp, $author, etc"
$res=$q->getrow();
}
i assume its not seeing an array, and thats why its not showing anything...what does that approved = 'Y' do?
thx
Jules
here is what i did:
$f=8;
chdir("./forums");
require "common.php";
$number=3;
$ssSQL = "SELECT id, subject, author, host, datestamp, body FROM $ForumTableName, $ForumTableName"."_bodies WHERE $ForumTableName.id=$ForumTableName"."_bodies.id AND approved='Y' ORDER BY datestamp DESC LIMIT $number";
$q->query($DB, $ssSQL);
$res=$q->getrow();
while(is_array($res)) {
$date = $res["datestamp"];
$host = $res["host"];
$subject = $res["subject"];
$author = $res["author"];
$body = $rec["body"];
// html part
echo "$datestamp, $author, etc"
$res=$q->getrow();
}
i assume its not seeing an array, and thats why its not showing anything...what does that approved = 'Y' do?
thx
Jules
Jules
Re: last post including msg body... May 15, 2001 02:25PM |
Re: last post including msg body... May 15, 2001 05:45PM |
Jules
Re: last post including msg body... May 15, 2001 07:19PM |
i doubt its the html part but here it is:
echo "<div align=\"center\">";
echo "<table border=\"0\" width=\"90%\" cellspacing=\"5\">";
echo "<tr>";
echo "<td width=\"100%\" colspan=\"3\" bgcolor=\"#800080\"><b><font class=\"vb2\">$datestamp</font></b></td>";
echo "</tr>";
echo "<tr>";
echo "<blockquote>";
echo "<td bgcolor=\"#000000\" valign=\"top\" align=\"left\" width=\"100%\">";
echo "<font class=\"vw2\"><p>$subject</p></font>";
echo "<font class=\"text2\"><p>";
echo "$body";
echo "</p></font>";
echo "</td>";
echo "</blockquote>";
echo "</tr>";
echo "<tr>";
echo "<td width=\"100%\" colspan=\"3\" bgcolor=\"#800080\"><p align=\"right\"><b><font class=\"vb1\">-- $author ($host)</font></b></td>";
echo "</tr>";
echo "</table>";
echo "</div>";
echo "<hr width=\"80%\" noshade size=\"1\" color=\"#800080\">";
i noticed i didnt put "$datelimit" in the select before the "AND"...think thats it?
thx
Jules
echo "<div align=\"center\">";
echo "<table border=\"0\" width=\"90%\" cellspacing=\"5\">";
echo "<tr>";
echo "<td width=\"100%\" colspan=\"3\" bgcolor=\"#800080\"><b><font class=\"vb2\">$datestamp</font></b></td>";
echo "</tr>";
echo "<tr>";
echo "<blockquote>";
echo "<td bgcolor=\"#000000\" valign=\"top\" align=\"left\" width=\"100%\">";
echo "<font class=\"vw2\"><p>$subject</p></font>";
echo "<font class=\"text2\"><p>";
echo "$body";
echo "</p></font>";
echo "</td>";
echo "</blockquote>";
echo "</tr>";
echo "<tr>";
echo "<td width=\"100%\" colspan=\"3\" bgcolor=\"#800080\"><p align=\"right\"><b><font class=\"vb1\">-- $author ($host)</font></b></td>";
echo "</tr>";
echo "</table>";
echo "</div>";
echo "<hr width=\"80%\" noshade size=\"1\" color=\"#800080\">";
i noticed i didnt put "$datelimit" in the select before the "AND"...think thats it?
thx
Jules
Re: last post including msg body... May 15, 2001 08:26PM |
Jules
Re: last post including msg body... May 16, 2001 02:09AM |
Re: last post including msg body... May 16, 2001 10:38AM |
Re: last post including msg body... May 29, 2001 05:18PM |
Re: last post including msg body... May 29, 2001 07:23PM |
This is my final script in my site..
[www.ipoh1.f2s.com]
I've add the script to replace any word that longer than 15 characters..
eg:
hellohellohellohellohelloeh
will change to hellohellohello...
=)
so, when you display the new post, it won't mess up your table.
------------------------------------------------------------------------------------------------
$f=1; // the forum number, as I only have one forum, I use number one
chdir("phorum/"); // change this to fit your system
include "common.php";
$number=1; // number of messages to show.
$SQL="select id, thread, author, subject, datestamp from $ForumTableName order by datestamp desc limit $number";
$q->query($DB, $SQL);
$rec=$q->getrow();
while(is_array($rec)){
$subject = explode (" ", $rec[subject]);
$i = 0;
while($subject[$i]) {
if(strlen($subject[$i]) >= 15){ $subject[$i] = substr ($subject[$i], 0, 15)."..."; }
$i++;
}
$subject = implode (" ", $subject);
echo "<font size=\"1\">
Post by<b> $rec[author] </b><br>
<br>Subject :
<a href=\"$forum_url/$read_page.$ext?f=$num&i=$rec[id]&t=$rec[thread]\"> $subject </a><br>
<br>$rec[datestamp]<br></font>\n";
$rec=$q->getrow();
}
chdir("..");
-----------------------------------------------------------------------------------------------------------------------
[www.ipoh1.f2s.com]
I've add the script to replace any word that longer than 15 characters..
eg:
hellohellohellohellohelloeh
will change to hellohellohello...
=)
so, when you display the new post, it won't mess up your table.
------------------------------------------------------------------------------------------------
$f=1; // the forum number, as I only have one forum, I use number one
chdir("phorum/"); // change this to fit your system
include "common.php";
$number=1; // number of messages to show.
$SQL="select id, thread, author, subject, datestamp from $ForumTableName order by datestamp desc limit $number";
$q->query($DB, $SQL);
$rec=$q->getrow();
while(is_array($rec)){
$subject = explode (" ", $rec[subject]);
$i = 0;
while($subject[$i]) {
if(strlen($subject[$i]) >= 15){ $subject[$i] = substr ($subject[$i], 0, 15)."..."; }
$i++;
}
$subject = implode (" ", $subject);
echo "<font size=\"1\">
Post by<b> $rec[author] </b><br>
<br>Subject :
<a href=\"$forum_url/$read_page.$ext?f=$num&i=$rec[id]&t=$rec[thread]\"> $subject </a><br>
<br>$rec[datestamp]<br></font>\n";
$rec=$q->getrow();
}
chdir("..");
-----------------------------------------------------------------------------------------------------------------------
Re: last post including msg body... May 30, 2001 02:52AM |
// this will show the last five posts in forum number 1.
// this will NOT do carrige returns, so the body text is returned as one line.
// I don't know what to do about it.
Here is how you detect carriage return :)
$rec=$q->getrow();
while(is_array($rec)){
$postmsg = nl2br($rec[body]);
echo " $postmsg<br>\n";
$rec=$q->getrow();
// this will NOT do carrige returns, so the body text is returned as one line.
// I don't know what to do about it.
Here is how you detect carriage return :)
$rec=$q->getrow();
while(is_array($rec)){
$postmsg = nl2br($rec[body]);
echo " $postmsg<br>\n";
$rec=$q->getrow();
Re: Hack to display last... on the index.php file May 30, 2001 07:12AM |
The script works great, but I'm having trouble integrating it in a PHPnuke box, but have also tried to put it under each comment on the index file (where the forums are listed and described).
Could anyone modify this hack so that it would run on this page? That may also help me getting it to run anywhere else since the problem seems to be with this line:
Could anyone modify this hack so that it would run on this page? That may also help me getting it to run anywhere else since the problem seems to be with this line:
$q->query($DB, $SQL);
Sorry, you do not have permission to post/reply in this forum.