Blackdogg Posted March 8, 2009 Posted March 8, 2009 Does anyone have a mod that when clicked shows the last 10 active topics in the forums :) Quote
Floydian Posted March 9, 2009 Posted March 9, 2009 Re: forum posts select topic from forum_topics order by last_post_date desc limit 10 Quote
Blackdogg Posted March 9, 2009 Author Posted March 9, 2009 Re: forum posts ok ive probably gone about this all wrong but am i anywhere near when i use this code <?php /** * @author Blackdogg * @copyright 2009 */ include "globals.php"; switch($_GET['action']) { case "forum": forum(); break; } function forum() { global $db,$ir,$c,$userid, $myf; print "Showing the last 10 forum posts <table width=75% cellspacing=1 class='table'><tr style='background:gray'> select topic from forum_topics order by last_post_date desc limit 10 "; } print "</table>"; ?> ive put a link onto the homepage to take you to a new page (code above) Be gentle with me im still learning :p Quote
John99 Posted March 9, 2009 Posted March 9, 2009 Re: forum posts ok ive probably gone about this all wrong but am i anywhere near when i use this code <?php /** * @author Blackdogg * @copyright 2009 */ include "globals.php"; switch($_GET['action']) { case "forum": forum(); break; } function forum() { global $db,$ir,$c,$userid, $myf; print "Showing the last 10 forum posts <table width=75% cellspacing=1 class='table'><tr style='background:gray'> select topic from forum_topics order by last_post_date desc limit 10 "; } print "</table>"; ?> ive put a link onto the homepage to take you to a new page (code above) Be gentle with me im still learning :p Rofl. Try this <?php require_once("globals.php"); echo 'Showing the last 10 forum posts '; mysql_query("SELECT `topic` FROM `forum_topics` ORDER BY `last_post_date` DESC LIMIT 10"); /* -- Show your stuff here!! */ ?> Or this is yours i done: <?php requre_once("globals.php"); $_GET['action'] = isset($_GET['action']) && is_string($_GET['action']) ? trim(strtolower($_GET['action'])) : ""; switch($_GET['action']) { case "forum": forum(); break; } function forum() { global $db,$ir,$c,$userid, $myf; print "Showing the last 10 forum posts <table width=75% cellspacing=1 class='table'><tr style='background:gray'>"; mysql_query("SELECT `topic` FROM `forum_topics` ORDER BY `last_post_date` DESC LIMIT 10"); /* -- Show your stuff here!! */ } print "</table>"; ?> Quote
Blackdogg Posted March 9, 2009 Author Posted March 9, 2009 Re: forum posts all im getting is a blank page :( also when i use requireonce it comes up as an undefined function error Quote
John99 Posted March 9, 2009 Posted March 9, 2009 Re: forum posts requre_once("globals.php"); I ment to say require_once lol Quote
Karlos Posted March 9, 2009 Posted March 9, 2009 Re: forum posts Should use include_once() :wink: Quote
John99 Posted March 9, 2009 Posted March 9, 2009 Re: forum posts Should use include_once() :wink: Can use any i want :wink: when using require_once if it dont find file page dies :P thats why i use that some times. Quote
Karlos Posted March 9, 2009 Posted March 9, 2009 Re: forum posts Could use... set_error_handler() :wink: Quote
Floydian Posted March 9, 2009 Posted March 9, 2009 Re: forum posts When I said: "select topic from forum_topics order by last_post_date desc limit 10", keep in mind that I don't know how your forum is setup. I don't know what the table names or column names are. I don't even know if it uses a database in the first place. The mysql query I posted is *representative* of how a query could be crafted that would get the last 10 topics posted in. I will say that your code is a long way off from what it needs to be, if indeed you are getting your data from a database. Quote
Blackdogg Posted March 9, 2009 Author Posted March 9, 2009 Re: forum posts Yeah im using the standard mc codes forum if thats any help :) Quote
Karlos Posted March 10, 2009 Posted March 10, 2009 Re: forum posts <?php include_once(DIRNAME(__FILE__) . '/globals.php'); echo 'Showing the last 10 forum posts! <table border="1" width="85%" class="table" cellspacing="0" cellpadding="2"> <tr style="text-align:center;"> <th>Topic</th> <th>Posts</th> <th>Started</th> <th>Last Post</th> </tr>'; $Select = $db->query("SELECT `ft_id`, `ft_name`, `ft_desc`, `ft_posts`, `ft_owner_id`, `ft_owner_name`, `ft_start_time`, `ft_last_id`, `ft_last_name`, `ft_last_time` FROM `forum_topics` ORDER BY `ft_last_time` DESC LIMIT 10"); while ($r = $db->fetch_row($Select)) { echo ' <tr style="text-align:center;"> <td> [url="forums.php?viewtopic='.intval($r['ft_id']).'&lastpost=1"]'.stripslashes($r['ft_name']).'[/url] [size="1"]'.stripslashes($r['ft_desc']).'[/size] </td> <td> '.number_format($r['ft_posts']).' </td> <td> '.date('F j Y, g:i:s a', $r['ft_start_time']).' By: [url="viewuser.php?u='.intval($r['ft_owner_id']).'"]'.stripslashes($r['ft_owner_name']).'[/url] </td> <td> '.date('F j Y, g:i:s a', $r['ft_last_time']).' By: [url="viewuser.php?u='.intval($r['ft_last_id']).'"]'.stripslashes($r['ft_last_name']).'[/url] </td> </tr>'; } echo ' </table>'; $h->endpage(); ?> I think... :wink: Quote
Blackdogg Posted March 10, 2009 Author Posted March 10, 2009 Re: forum posts thank you very much you my friend are an a* guy +1 for you :) Quote
John99 Posted March 10, 2009 Posted March 10, 2009 Re: forum posts $Select = $db->query("SELECT `ft_id`, `ft_name`, `ft_desc`, `ft_posts`, `ft_owner_id`, `ft_owner_name`, `ft_start_time`, `ft_last_id`, `ft_last_name`, `ft_last_time` FROM `forum_topics` ORDER BY `ft_last_time` DESC LIMIT 10"); How come its going off the page ? lol Quote
Karlos Posted March 10, 2009 Posted March 10, 2009 Re: forum posts Because i decided to put it in PHP tags not code tags. Quote
John99 Posted March 10, 2009 Posted March 10, 2009 Re: forum posts oh lol Just use code tags :D Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.