PDA

View Full Version : News on main page???


Spike
11-27-2004, 02:14 PM
Could I have the php code to put news from a forum to be put on the main page? Like yours... please

Cisyouc
11-28-2004, 08:37 AM
<?
// Main.php by Rogean
require('forums/config.php');
mysql_connect($dbhost, $dbuser, $dbpasswd);
@mysql_select_db("$dbname")or die(mysql_error());

//GET FORUM NEWS
$getnews=mysql_query("SELECT topic_id,forum_id,topic_title,topic_poster,topic_t ime,topic_views,topic_replies,topic_first_post_id FROM phpbb_topics WHERE forum_id='11' ORDER by topic_time DESC LIMIT 4");
while(list($topic[id],$forum[id],$topic[title],$to pic[poster],$topic[time],$topic[views],$topic[repl ies],$topic[firstpostid])=mysql_fetch_row($getnews )){

$newsbody=mysql_query("SELECT * FROM phpbb_posts_text WHERE post_id=$topic[firstpostid]");
$text=mysql_fetch_array($newsbody);

$userinfo=mysql_query("SELECT * FROM phpbb_users WHERE user_id=$topic[poster]");
$user=mysql_fetch_array($userinfo);

$text[post_text]=str_replace("\n", "<br>", $text[post_text]);
$text[post_text]=str_replace("[b]", "<b>", $text[post_text]);
$text[post_text]=str_replace("[/b]", "</b>", $text[post_text]);
$text[post_text]=str_replace("[i]", "<i>", $text[post_text]);
$text[post_text]=str_replace("[/i]", "</i>", $text[post_text]);
$text[post_text]=str_replace("<", "<", $text[post_text]);
$text[post_text]=str_replace(">", ">", $text[post_text]);



echo "<div class=\"content\">
<span class=\"title\">$text[post_subject]</span><br>
<font size=1>Posted by: $user[username] :: $topic[replies] Replies :: $topic[views] Views<br><br>
$text[post_text]
</div>
<hr width=80% color=darkblue align=left>";
}
?>