list last 5 post

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Scam Warning
kyo
Registered User
Posts: 9
Joined: Mon Jun 09, 2008 4:36 pm

Re: list last 5 post

Post by kyo »

Hi, tommeke thanks again for answering. ;)

What exactly do you mean by database?
tommekemc
Registered User
Posts: 457
Joined: Wed May 14, 2008 6:36 pm
Location: Belgium
Contact:

Re: list last 5 post

Post by tommekemc »

the things where everything is saved.
mySQL or whatever you use.
my sig
my projects

images deleted because of the 6kb (wtf?) rule...
kyo
Registered User
Posts: 9
Joined: Mon Jun 09, 2008 4:36 pm

Re: list last 5 post

Post by kyo »

I don't think I know enough about mySQL to get that kind of info.

Could you take a look at it? I think there might be other people looking for this as well?

Thanks in advance.
tommekemc
Registered User
Posts: 457
Joined: Wed May 14, 2008 6:36 pm
Location: Belgium
Contact:

Re: list last 5 post

Post by tommekemc »

Code: Select all

require_once("connect.php");
$number=0;
$forumQ=mysql_query("SELECT t.topic_id, t.forum_id, t.topic_title, t.topic_time, t.topic_first_poster_name, f.forum_name
FROM (phpbb_topics t)
LEFT JOIN phpbb_forums f ON (t.forum_id = f.forum_id)
WHERE t.topic_approved=1
LIMIT 5");
while($forumRow = mysql_fetch_row($forumQ)){
$number++;
$forumRow[3]=date('D M d, Y g:i a', $forumRow[3]);
echo $number."<a href=YOUR LINK TO THE FORUM/viewtopic.php?f=".$forumRow[1]."&t=".$forumRow[0].">".$forumRow[2]."</a> posted in ".$forumRow[5]." by ".$forumRow[4]." on ".$forumRow[3]."<br>";
}
try this :)
my sig
my projects

images deleted because of the 6kb (wtf?) rule...
divinemanwah
Registered User
Posts: 34
Joined: Sat Sep 08, 2007 11:48 am

Re: list last 5 post

Post by divinemanwah »

hello,
i had this codes to work, but the only problem is i don't know how to get only the last 3 topics from a SPECIFIC forum. this code could only list the last topics from the whole forum.

example:
i have forum ABC with category abc, the only topics that i want to get are those from category abc

any ideas?

thanks!! :D
tommekemc
Registered User
Posts: 457
Joined: Wed May 14, 2008 6:36 pm
Location: Belgium
Contact:

Re: list last 5 post

Post by tommekemc »

find:

Code: Select all

WHERE topic_approved=1
add after:

Code: Select all

AND forum_id=YOUR FORUM ID
if it doesn't work, please show me your source.
my sig
my projects

images deleted because of the 6kb (wtf?) rule...
blusterblade
Registered User
Posts: 3
Joined: Tue Jul 01, 2008 8:15 am
Location: Belgium
Contact:

Re: list last 5 post

Post by blusterblade »

I understand the code you guys provided..its just that i dont realy know where to put it to get it to show correctly on the 'main' page. Im using the subsilver2 style phpBB3.
I created the connect.php

Thanks,
tommekemc
Registered User
Posts: 457
Joined: Wed May 14, 2008 6:36 pm
Location: Belgium
Contact:

Re: list last 5 post

Post by tommekemc »

well, if you want to show it on your forum it should be in the index.php
I'll start on a correct mod for that.
my sig
my projects

images deleted because of the 6kb (wtf?) rule...
divinemanwah
Registered User
Posts: 34
Joined: Sat Sep 08, 2007 11:48 am

Re: list last 5 post

Post by divinemanwah »

tommekemc wrote:find:

Code: Select all

WHERE topic_approved=1
add after:

Code: Select all

AND forum_id=YOUR FORUM ID
if it doesn't work, please show me your source.

it worked perfectly as i expected!! thanks!!

i also added this code:

Code: Select all

putenv('TZ=YUOR CONTINENT/YOUR REGION');
in case that you want to use your timezone.
for a list of timezones, here it is :D
http://www.expertsrt.com/tutorials/Matt/zone.tab.txt
kyo
Registered User
Posts: 9
Joined: Mon Jun 09, 2008 4:36 pm

Re: list last 5 post

Post by kyo »

Hi Tommeke, that code worked perfect for me, thanks a lot!
grylmz
Registered User
Posts: 1
Joined: Sat Jul 12, 2008 5:22 pm

Re: list last 5 post

Post by grylmz »

I try this code and worked successfully but i have a problem about characters.

my forum's language is turkish but when i list the latest posts with this code turkish characters seems false.

for example

"Göz Makyajı Hileleri..." seems like
Göz Makyajı Hileleri...

what can i do?
tommekemc
Registered User
Posts: 457
Joined: Wed May 14, 2008 6:36 pm
Location: Belgium
Contact:

Re: list last 5 post

Post by tommekemc »

this can be solved by writing the characters in their HTML valid way, for example, you have to write:

Code: Select all

&
as
&
my sig
my projects

images deleted because of the 6kb (wtf?) rule...
acctman
Registered User
Posts: 103
Joined: Thu Feb 09, 2006 5:48 pm

Re: list last 5 post

Post by acctman »

tommekemc wrote:

Code: Select all

require_once("connect.php");
$number=0;
$forumQ=mysql_query("SELECT t.topic_id, t.forum_id, t.topic_title, t.topic_time, t.topic_first_poster_name, f.forum_name
FROM (phpbb_topics t)
LEFT JOIN phpbb_forums f ON (t.forum_id = f.forum_id)
WHERE t.topic_approved=1
LIMIT 5");
while($forumRow = mysql_fetch_row($forumQ)){
$number++;
$forumRow[3]=date('D M d, Y g:i a', $forumRow[3]);
echo $number."<a href=YOUR LINK TO THE FORUM/viewtopic.php?f=".$forumRow[1]."&t=".$forumRow[0].">".$forumRow[2]."</a> posted in ".$forumRow[5]." by ".$forumRow[4]." on ".$forumRow[3]."<br>";
}
try this :)
does this work with phpbb3?
tommekemc
Registered User
Posts: 457
Joined: Wed May 14, 2008 6:36 pm
Location: Belgium
Contact:

Re: list last 5 post

Post by tommekemc »

it does, but it's not dBal secure.
it should be used on an external page (no dBal is used).
my sig
my projects

images deleted because of the 6kb (wtf?) rule...
onmillertime
Registered User
Posts: 7
Joined: Fri Jun 05, 2009 11:44 am

Re: list last 5 post

Post by onmillertime »

I am trying to post the last 5 posts in the sidebar of my B2E blog. I have been using HTML containers provided by the program to populate the sidebars and so far it has worked quite well....until this.

I am completely new at this and totally confused. I have created the connect.php file and put it in the root folder of my blog. Now I need to figure out the code to put in the html container to get the posts to show up. This is what I have tried.
<?
require_once("connect.php");
$number=0;
$forumQ=mysql_query("SELECT topic_id, forum_id, topic_title
FROM phpbb_topics
WHERE topic_approved=1
LIMIT 5");
while($forumRow = mysql_fetch_row($forumQ)){
$number++;
echo $number."<a href=FORUMADDRESS/viewtopic.php?f=".$forumRow[1]."&t=".$forumRow[0].">".$forumRow[2]."</a><br>";
}
?>
Of course I changed my forum address but when I save it shows up at this on my sidebar...

".$forumRow[2]."
"; } ?>

Can someone please help me figure out what I need to do to get this to show up. I have read through this entire thread and tried just about everything includind the reference to Wordpress and nothing has worked. I am pretty sure I am missing some php code or something in the html container but I am not sure what it is?
Locked

Return to “[3.0.x] MOD Requests”