UseBB Community

The official board for UseBB help and discussion

UseBB Community » Help & Support » How can i put lastest post in UseBB to my html page?

How can i put lastest post in UseBB to my html page?

Moderators: Gaia.

Page: 1 2 >

Author Post
Member
Registered: Apr 2006
Posts: 6
for 5-10 subjects ?

Sorry for dummy question ,cuz i really wanna use this forum quickly
full features and function for minialism like me :)
Developer
Registered: Apr 2004
Posts: 2215
Location: Belgium
You can connect to the database and perform a query to call the latest topics, and output them in a list or something similar.

<?php

mysql_connect('localhost', 'user', 'pass');
mysql_select_db('database');

$r = mysql_query("SELECT t.id, t.topic_title
FROM usebb_posts p, usebb_topics t, usebb_forums f
WHERE f.auth LIKE '0%' AND t.forum_id = f.id AND p.id = t.last_post_id
ORDER BY p.post_time DESC LIMIT 10");

echo '<ul>';
while ( $out = mysql_fetch_array($r) ) {

echo '<li><a href="forum/topic.php?id='.$out['id'].'">';
echo htmlspecialchars($out['topic_title']).'</a></li>';

}
echo '</ul>';

?>


Edit your user, password and database name in the first statements. Eventually, use mysqli* functions if you are on PHP 5 and use MySQL >= 4.1.
_______________
--Dietrich (developer)
UseBB roadmap, dev mailing list & weblog
« Last edit by Dietrich on Mon Apr 24, 2006 6:34 am. »
Member
Registered: Apr 2006
Posts: 6
Big thanks for quickly reply :) but i still have a problem
Is that can insert on html page ? or just only .php page so i should use iframe function to insert .php page that
use your script ,isn't it ?

Thank
Mhoo
Developer
Registered: Apr 2004
Posts: 2215
Location: Belgium
Of course, you need to put that in a .php page.
_______________
--Dietrich (developer)
UseBB roadmap, dev mailing list & weblog
Member
Registered: Apr 2006
Posts: 6
Thanks
Dietrich a lot :)
Member
Registered: Apr 2006
Posts: 6
Fatal error: Call to undefined function: () in /usr/local/psa/home/vhosts/mhoomhoo.com/httpdocs/001.php on line 6

:<

How can i do for next step?
Developer
Registered: Apr 2004
Posts: 2215
Location: Belgium
Oops, change
$r = $mysql_query("SELECT t.id, t.topic_title
into
$r = mysql_query("SELECT t.id, t.topic_title
_______________
--Dietrich (developer)
UseBB roadmap, dev mailing list & weblog
Member
Registered: Apr 2006
Posts: 6
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /usr/local/psa/home/vhosts/mhoomhoo.com/httpdocs/bb/001.php on line 12

:shock:


sorry for same question but i don't have any experience from php ..

thankz
Developer
Registered: Apr 2004
Posts: 2215
Location: Belgium
What does it say when you replace
    ORDER BY p.post_time DESC LIMIT 10");
with
    ORDER BY p.post_time DESC LIMIT 10") or die(mysql_error());
?
_______________
--Dietrich (developer)
UseBB roadmap, dev mailing list & weblog
Member
Registered: Apr 2006
Posts: 6
that's all of content that show on the page that i request from forum :>
Member
Registered: Mar 2005
Posts: 196
Location: Hungary
Can it be done that it displays like:

[ForumName]TopicTitle

like

[Support]Bug in smth
_______________
Long Live Rock n' Roll!
Member
Registered: May 2006
Posts: 29
bastya_elvtars wrote
Can it be done that it displays like:

[ForumName]TopicTitle

like

[Support]Bug in smth

Yes, it can. How about this?
<?php

mysql_connect('localhost', 'root', '');
mysql_select_db('usebb');

$result = mysql_query("SELECT usebb_topics.id, usebb_topics.topic_title, usebb_forums.name
FROM usebb_posts, usebb_topics, usebb_forums
WHERE usebb_forums.auth LIKE '0%' AND usebb_topics.forum_id = usebb_forums.id AND usebb_posts.id = usebb_topics.last_post_id
ORDER BY usebb_posts.post_time DESC LIMIT 10") or die(mysql_error());

echo '<ul>';
while ( $out = mysql_fetch_assoc($result) )
{
echo '<li><a href="forum/topic.php?id='.$out['id'].'">';
echo '[' . htmlspecialchars($out['name']) . '] ' . htmlspecialchars($out['topic_title']) . '</a></li>';
}
echo '</ul>';

?>
Member
Registered: Mar 2005
Posts: 196
Location: Hungary
Thanks! :)
_______________
Long Live Rock n' Roll!
Member
Registered: May 2006
Posts: 29
You're welcome.
Member
Registered: Apr 2007
Posts: 13
I managed to install this and get it working, however, it is coded to work with the non-search engine friendly urls.

How would I need to change the code to work if I have friendly URLs enabled?

Dawn
Moderator
Registered: Oct 2005
Posts: 444
Location: canada
change the path.


<a href="forum/topic.php?id='.$out['id'].'">


TO


<a href="forum/topic-'.$out['id'].'.html">
Member
Registered: Apr 2007
Posts: 13
Fantastic! That worked like a charm!
Thanks, Gaia!

Dawn

BTW, this community has some of the most responsive and helpful folks I've come across on the Web.
Member
Registered: Oct 2007
Posts: 5
Good idea, this is exactly what I'm looking for, or close to that. I have a question - what if I want it to just display the latest 5 topic links from a particular forum? Thanks :)
Moderator
Registered: Oct 2005
Posts: 444
Location: canada
This is the query that I use in uPortal. Just alter the variables with your own numbers:

SELECT t.id, t.topic_title, t.count_replies, p.content, p.post_time, p.poster_id, u.displayed_name FROM ".TABLE_PREFIX."topics t, ".TABLE_PREFIX."posts p, ".TABLE_PREFIX."members u WHERE t.forum_id = $fid AND t.status_sticky = 0 AND p.id = t.first_post_id AND u.id = p.poster_id ORDER BY p.post_time DESC LIMIT $limit


$fid = the forum ID you want the items from.
$limit = how many you want displayed.
Member
Registered: Oct 2007
Posts: 5
I'm getting errors, probably put it at the wrong place. Can you post the entire query?
Moderator
Registered: Oct 2005
Posts: 444
Location: canada
This should work. Unfortunately I don't have the means right now to test it. Just post the errors you get and I might be able to point you in the right direction.


<?php

mysql_connect('localhost', 'user', 'pass');
mysql_select_db('database');

$r = mysql_query("SELECT t.id, t.topic_title, t.count_replies, p.content, p.post_time, p.poster_id, u.displayed_name FROM ".TABLE_PREFIX."topics t, ".TABLE_PREFIX."posts p, ".TABLE_PREFIX."members u WHERE t.forum_id = $fid AND t.status_sticky = 0 AND p.id = t.first_post_id AND u.id = p.poster_id ORDER BY p.post_time DESC LIMIT $limit");

echo '<ul>';
while ( $out = mysql_fetch_array($r) ) {

echo '<li><a href="forum/topic.php?id='.$out['id'].'">';
echo htmlspecialchars($out['topic_title']).'</a></li>';

}
echo '</ul>';

?>


Also, don't forget to change the info/variables in the code to your own.
Member
Registered: Oct 2007
Posts: 5
I'm getting this error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result 
resource in /www/110mb.com/b/i/t/a/g/_/_/_/bitag/htdocs/bac.php on line 9


The weird thing is that I can get the very first code posted by the admin to work and show what I want (new threads from forum 6, which only has 1 topic at the moment) but it displays the link 6 times :(

Also, do I have anything special to add to the php includes or will this suffice?

<?php
include("bac.php");
?>
« Last edit by Marikina on Thu Oct 25, 2007 7:14 am. »
Moderator
Registered: Oct 2005
Posts: 444
Location: canada
Sorry I didn't get back to you, I have been working like crazy. I will take a look at the coding tonight when I get home and will try to get something functional for you.
Moderator
Registered: Oct 2005
Posts: 444
Location: canada
The following worked for me:


<?php

mysql_connect('localhost', 'user', 'pass');
mysql_select_db('database');

$result = mysql_query("SELECT t.id, t.topic_title, t.count_replies, t.count_views, t.status_locked, p.content, p.post_time, p.poster_id, u.displayed_name FROM usebb_topics t, usebb_posts p, usebb_members u WHERE t.forum_id = 2 AND t.status_sticky = 0 AND p.id = t.first_post_id AND u.id = p.poster_id ORDER BY p.post_time DESC LIMIT 5");

echo '<ul>';

while ($news = mysql_fetch_array($result)) {

echo '<li><a href="forum/topic.php?id='.$news['id'].'">';
echo htmlspecialchars($news['topic_title']).'</a></li>';

}

echo '</ul>';

?>
« Last edit by Gaia on Fri Oct 26, 2007 5:21 am. »
Member
Registered: Oct 2007
Posts: 5
Thanks, it's working now! :)

Page: 1 2 >

UseBB Community » Help & Support » How can i put lastest post in UseBB to my html page?

UseBB Community is powered by UseBB 1 Forum Software