Not Solved [Need Help]Latest Threads on HomePage
#1
Not Solved Exclamation 
Hi,

How can I show one [Only The Newest] Thread On My homepage

my homepage is html file the forum is on /forum/


Thanks !!!
Reply
#2
Not Solved
you can't do that on a normal html page. I advice you to copy the whole code into a phpfile and add this piece of code where you want to show the latest thread.
<?php
require "forum/global.php";
$query = mysql_query("SELECT * FROM ".TABLE_PREFIX."threads WHERE 1=1 ORDER BY dateline DESC LIMIT 0,1");
$thread = mysql_fetch_array($query);
echo '<a href="forum/showthread.php?tid='.$thread['tid'].'">'.$thread['subject'].'</a>';
?>

The part after echo is a normal html link. You can always change the html a bit, but I advice you to keep this link intact.
Reply
#3
Not Solved
Thank You !!!
Working Great
Reply
#4
Not Solved
Please replace the query with the following so that drafts are not shown:
$query = mysql_query("SELECT * FROM ".TABLE_PREFIX."threads WHERE visible = '1' ORDER BY dateline DESC LIMIT 0,1");
Greets,
Michael
-------------
[Image: donation_drive_sig.png]
Reply
#5
Not Solved
Hmm, but this doesnt seem to work for me. My forum is on / but my site is on /kb and it won't link correctly. Can this be fixed?
Ep2.nl Developers Community running on a modded version of MyBB!
clean URI's, Mass PM, Custom BB, semantic, link to threads, topics, forums, google, wikipedia, flickr, php.net, Thread Templates and more...
Reply
#6
Not Solved
Replace the line
echo '<a href="forum/showthread.php?tid='.$thread['tid'].'">'.$thread['subject'].'</a>';
with
echo '<a href="http://www.your_url.tld/showthread.php?tid='.$thread['tid'].'">'.$thread['subject'].'</a>';
Replace http://www.your_url.tld/showthread.php with the real URL to your forums.
Greets,
Michael
-------------
[Image: donation_drive_sig.png]
Reply
#7
Not Solved
hello everybody,
I hope you are having a great new year start.
The above code is not working in my case.
it says

Direct initialization of this file is not allowed.

Please make sure IN_MYBB is defined.

what should I do ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)