last 10 topics

This forum is now closed as part of retiring phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Post Reply
dirknet
Registered User
Posts: 4
Joined: Sat May 03, 2003 2:46 pm

last 10 topics

Post by dirknet » Fri Jun 20, 2003 6:56 pm

Hi, we are creating a php file that reads the 10 last posts from the phpbb database.
It looks like this
</script>
<h3>10 laatste forumposts</h3>
<!-- <p>
Dit is het begin van: url3.php

php-Script gemaakt door Ron van Setten.
Licht aangepast door Leon Klomp.
Holland ! Holland !

</p>-->

<?php
$host = '*****';
$user = '*****';
$pw = '*****';
$db = 'phpbb';
$table = 'phpbb_posts';
$table2 = 'phpbb_users';
$table3 = 'phpbb_topics';

$connect = @mysql_connect($host,$user,$pw);

if (!$connect)
{
die('<FONT COLOR="red">Verbinding mislukt</FONT>: '.mysql_error());
}
else
{
if($pw == '')
{
$pw = 'geen password opgegeven';
}

$select_db = @mysql_select_db($db);

if (!$select_db)
{
die('<FONT COLOR="red">Selecteren database '.$db.' is niet gelukt</FONT>: '.mysql_error());
}
else
{
$sql = 'SELECT a.post_time
,a.post_id
,a.topic_id
,a.poster_id
,b.username
,c.topic_title
FROM '.$table.' AS a
,'.$table2.' AS b
,'.$table3.' AS c
WHERE a.poster_id=b.user_id AND a.topic_id=c.topic_id
ORDER BY post_time DESC
LIMIT 10'
;

$query = @mysql_query($sql);

if (!$query)
{
die('<FONT COLOR="red">query not ok</FONT>: '.mysql_error());
}
else
{
echo '<TABLE>';
/* echo ' <CAPTION>';
echo ' Laatste 10';
echo ' </CAPTION>';*/

while ($data = @mysql_fetch_assoc($query))

if (!$data)
{
die('<FONT COLOR="red">Overhalen data mislukt</FONT>: '.mysql_error());
}
else
{
echo ' <TR>';
echo ' <TD>';

echo $data['username'];
echo ' </TD>';
echo ' <TD>';
$url = '<A HREF=http://www.vizatti.com/apps/forum/viewt ... ?p='.$data['post_id'].'#'.$data['post_id'].' target="werkblad">'.$data['topic_title'].'</A>';
echo $url ;
echo ' </TD>';
echo ' <TD>';
echo $data ['post_time'];
echo ' </TR>';
}

mysql_free_result($query);


mysql_close($connect);

echo '</TABLE>';
}
}
}
?>


The result is, it displays the last 10 forum titels in a 3 columnx10 rows table, first column = username, second column = topic title in URL form, third one = date/time). The last part echoes it on the screen. I have only one problem with this: I cant get it to print a proper date/time, it displays the user_time Unix-timestamp ( The timestamp is the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).


Please help :oops:

d.

Stylee
Registered User
Posts: 54
Joined: Mon May 19, 2003 10:15 pm

Post by Stylee » Fri Jun 20, 2003 8:34 pm

Well, that all looks greek to me, but I sure cant wait until you get it done :D

User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Post by drathbun » Fri Jun 20, 2003 9:04 pm

Have a look at this topic. Even if you don't want to use it as it is, you can see how to use the conversion routines built in to phpbb to get the date / time in the proper format, including respecting the user's selection for their local time zone.

Dave
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image

dirknet
Registered User
Posts: 4
Joined: Sat May 03, 2003 2:46 pm

Post by dirknet » Sat Jun 21, 2003 11:58 am

I will have a look at it, I will come back with my findings...
tbc....

cheers,
D

Post Reply

Return to “[2.0.x] MOD Requests”