MyBB Community Forums

Full Version: Displaying News on Homepage
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12
Thx a lot it works now Smile
I've stripped te code to:

<?php
require_once ("global.php");
require_once("./forum/inc/functions_post.php");


$mysqlhost = "***";
$mysqlusername = "***";
$mysqlpassword = "***";
$mysqldbselect = "***";
$prefix = "mybb_";
$fid = "2";

mysql_select_db($mysqldbselect, mysql_connect($mysqlhost,$mysqlusername,$mysqlpassword));

$message[post] = postify($message[post], $allowhtml="yes", $allowmycode="yes", $allowsmilies="yes", $allowimgcode="yes", $archive=0);

$query = mysql_query("SELECT t.tid,t.subject FROM ".$prefix."threads t LEFT JOIN ".$prefix."posts p ON (t.tid = p.tid) WHERE t.fid='".$fid."' AND t.visible='1' AND t.closed NOT LIKE 'moved|%'") or die(mysql_error());
while($news = mysql_fetch_array($query))
{
echo "<a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['subject']."</a><a href=\"./forum/member.php?action=profile&amp;uid=".$news['uid']."\">".$news['username']."</a><a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['replies']."</a>".$news['message']."<br /><br />";
}
?>

It works fine now.
But I made it into an inline frame but when you click on the topic it is not opening in a new window how to fix it?

And I also would like to have a limit of 5 topics.

Thanx in advance.
Change:
while($news = mysql_fetch_array($query))
{
echo "<a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['subject']."</a><a href=\"./forum/member.php?action=profile&amp;uid=".$news['uid']."\">".$news['username']."</a><a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['replies']."</a>".$news['message']."<br /><br />";
}
to:
while($news = mysql_fetch_array($query))
{
echo "<a href=\"./forum/showthread.php?tid=".$news['tid']."\" target=\"_blank\">".$news['subject']."</a><a href=\"./forum/member.php?action=profile&amp;uid=".$news['uid']."\">".$news['username']."</a><a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['replies']."</a>".$news['message']."<br /><br />";
}
Thanx Peter Wink
where do i put this code. It will work for what I need, but do i put it in index.php?
also, you gotta call "postify" within the while loop
_

based on your code, the while loop should look like this

while($news = mysql_fetch_array($query))
{
$news['message'] = postify($news['message'], $allowhtml="yes", $allowmycode="yes", $allowsmilies="yes", $allowimgcode="yes", $archive=0);

echo "<a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['subject']."</a><a href=\"./forum/member.php?action=profile&amp;uid=".$news['uid']."\">".$news['username']."</a><a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['replies']."</a>".$news['message']."<br /><br />";
}

also, i do believe you can reduce your code to this


<?php
require_once ("global.php");
require_once("./forum/inc/functions_post.php");

$prefix = "mybb_"; // forum prefix
$fid = "2"; // news forum id

$query = $db->query("SELECT t.tid,t.subject FROM ".$prefix."threads t LEFT JOIN ".$prefix."posts p ON (t.tid = p.tid) WHERE t.fid='".$fid."' AND t.visible='1' AND t.closed NOT LIKE 'moved|%'") or die(mysql_error());
while($news = mysql_fetch_array($query))
{
$news['message'] = postify($news['message'], $allowhtml="yes", $allowmycode="yes", $allowsmilies="yes", $allowimgcode="yes", $archive=0);

echo "<a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['subject']."</a><a href=\"./forum/member.php?action=profile&amp;uid=".$news['uid']."\">".$news['username']."</a><a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['replies']."</a>".$news['message']."<br /><br />";
}
?>
I got this code:

<?php
require_once ("global.php");
require_once("./forum/inc/functions_post.php");

$limit = "5"; // The amount of annoucements to show


$mysqlhost = "***";
$mysqlusername = "***";
$mysqlpassword = "***";
$mysqldbselect = "***";
$prefix = "mybb_";
$fid = "2";

mysql_select_db($mysqldbselect, mysql_connect($mysqlhost,$mysqlusername,$mysqlpassword));

$message[post] = postify($message[post], $allowhtml="yes", $allowmycode="yes", $allowsmilies="yes", $allowimgcode="yes", $archive=0);

$query = mysql_query("SELECT t.tid,t.subject FROM ".$prefix."threads t LEFT JOIN ".$prefix."posts p ON (t.tid = p.tid) WHERE t.fid='".$fid."' AND t.visible='1' AND t.closed NOT LIKE 'moved|%'") or die(mysql_error());
while($news = mysql_fetch_array($query))
{
echo "<p style=\"padding-left: 25px; font-size: 9pt; font-family: Trebuchet MS; text-decoration: none; alink: #F5F5F5; link: #91E902; vlink: #F5F5F5;\"><a href=\"./forum/showthread.php?tid=".$news['tid']."\" target=\"_blank\">".$news['subject']."</a></p>";
}
?>

But this:

text-decoration: none; alink: #F5F5F5; link: #91E902; vlink: #F5F5F5


Part isn't working

it shows like this:

Topic and no rollover

But is has to be:

Topic and rollover with: #F5F5F5
and it only shows the first 5 topic of the whole forum but it's has got te be te 5 latest.
Dude, alink and vlink aren't css. Give them classes like <p class="result"> and use the following css in either an external style sheet or between the style tags:

.result {
	padding-left: 25px;
	font-size: 9pt;
	font-family: Trebuchet MS;
}
.result a {
	color: #91E902;
	text-decoration: none;
}
.result a:active {
	color: #F5F5F5;
}
.result a:visited {
	color: #F5F5F5;
}

That should get the effect you are looking for.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12