Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 342
0 Users 10 Guests Online

Newest thread for forum.

okay find in forum.php

This is your new default part if forum.php

Code

default:
echo ("<table width='100%' cellpadding='0'>");

$fetch1 = mysql_query("SELECT * FROM `forum_category`");
while ($category = mysql_fetch_array($fetch1))
{
echo ("<tr>
<td id='mains' width='75%'><b>$category[name]</b></td><td id='mains'><b>Newest Thread</b></td>
</tr>
");
$fetch2 = mysql_query("SELECT * FROM `forum_topic` WHERE `cat_id` = '$category[id]'");
while ($topic = mysql_fetch_array($fetch2))
{
$grab = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$topic[id]' ORDER BY `id` DESC LIMIT 0, 1");
$newest = mysql_fetch_array($grab);

$threadtitle = "$newest[title]";
$bbctt1 = BBCODE($threadtitle);
echo ("<tr>
<td id='fields' width='75%'><a href='?page=forum&id=$topic[id]'>$topic[name]</a><br><i>$topic[description]</i></td><td id='fields'><a href='?page=forumdisplay&id=$newest[id]'>$bbctt1<br>$newest[poster]</a></td>
</tr>
");
}
}
echo ("</table>");
$rows = mysql_num_rows($fetch1);
if ($rows == 0)
{
echo ("<center><b>Forum is Empty<b></center>");
}
break;


basically we grabbed the news thread in that topic by its id with this code
Code

$grab = mysql_query("SELECT * FROM `forum_thread` WHERE `id` = '$topic[id]' ORDER BY `id` DESC LIMIT 0, 1");
$newest = mysql_fetch_array($grab);

$threadtitle = "$newest[title]";
$bbctt1 = BBCODE($threadtitle);

And we displayed using.
Code

<td id='fields'><a href='?page=forumdisplay&id=$newest[id]'>$bbctt1<br>$newest[poster]</a>


Pretty simple so enjoy.
SkillMaster
Author:
SkillMaster
Views:
2204
Rating:
Posted on Saturday 23rd June 2007 at 09:04 PM
SkillMaster
SkillMaster
Code

default:
echo ("<table width='100%' cellpadding='0'>");

$fetch1 = mysql_query("SELECT * FROM `forum_category`");
while ($category = mysql_fetch_array($fetch1))
{
echo ("<tr>
<td id='mains' width='75%'><b>$category[name]</b></td><td id='mains'><b>Newest Thread</b></td>
</tr>
");
$fetch2 = mysql_query("SELECT * FROM `forum_topic` WHERE `cat_id` = '$category[id]'");
while ($topic = mysql_fetch_array($fetch2))
{
$grab = mysql_query("SELECT * FROM `forum_thread` WHERE `thr_id` = '$topic[id]' ORDER BY `id` DESC LIMIT 0, 1");
$newest = mysql_fetch_array($grab);

$threadtitle = "$newest[title]";
$bbctt1 = BBCODE($threadtitle);
echo ("<tr>
<td id='fields' width='75%'><a href='?page=forum&id=$topic[id]'>$topic[name]</a><br><i>$topic[description]</i></td><td id='fields'><a href='?page=forumdisplay&id=$newest[id]'>$bbctt1<br>$newest[poster]</a></td>
</tr>
");
}
}
echo ("</table>");
$rows = mysql_num_rows($fetch1);
if ($rows == 0)
{
echo ("<center><b>Forum is Empty<b></center>");
}
break;

That one should work
Posted on Saturday 23rd June 2007 at 08:55 PM
SkillMaster
SkillMaster
It worked fine for me
let me dub check.
Posted on Saturday 23rd June 2007 at 05:51 PM
dtnet
dtnet
Sorry, I was a little too quick to answer your tutorial: The script is only showing the first Thread ever made in the forum. Not the newest thread
Posted on Saturday 23rd June 2007 at 12:38 PM
cyruswu
cyruswu
Nice job.
Posted on Friday 22nd June 2007 at 10:16 PM
SkillMaster
SkillMaster
im so great first go haha. joking
Posted on Friday 22nd June 2007 at 10:00 PM
dtnet
dtnet
Great. Works perfectly! :D