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
I've got a little (hope so Wink) problem.
[Image: untitled24gb.gif]
My situation is the above image I would like that there are only showed of 20 characters an then "...".

Here is my code:
<?php
require_once ("global.php");
require_once ("./forum/inc/functions_post.php");
?><html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Fearless :: Established since januari 2006</title>
<link href="http://fearless.owiosa1.nl/stylesheet.css" rel="stylesheet" type="text/css">
</head>

<body background="http://fearless.owiosa1.nl/images/activetopics_bg.gif" class="navigation">
<?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 = $db->query("
   SELECT t.tid,t.subject
   FROM mybb_threads t   LEFT JOIN mybb_posts p ON (t.tid = p.tid)
   AND t.visible=1
   AND t.closed NOT LIKE 'moved|%'
   ORDER BY t.dateline DESC
   LIMIT $limit")
or die($db->error());
while($news = $db->fetch_array($query))
{
echo "<div style=\"padding:3px\"><a href=\"./forum/showthread.php?tid=".$news['tid']."\" target=\"_blank\">".$news['subject']."</a></div>";
}
?>
</body>

</html>

Thx in advance.
Add this over your echo
		if(strlen($news['subject']) > 20) {
			$news['subject'] = substr($news['subject'], 0, 20);
			$news['subject'] .= "...";
		}
Can you pls tell were I need to paste it. (Copy my code and paste your in it) (Sorry I don't know enything about php coding).

Thx a lot in advance

Well I did tell you. oh well.

while($news = $db->fetch_array($query))
{
if(strlen($news['subject']) > 20) {
     $news['subject'] = substr($news['subject'], 0, 20);
     $news['subject'] .= "...";
}
echo "<div style=\"padding:3px\"><a href=\"./forum/showthread.php?tid=".$news['tid']."\" target=\"_blank\">".$news['subject']."</a></div>";
}
Yes it's working thx a lot m8!
No problem Smile
Now I've got another problem it's not related to this topic even not related to Mybb at all but I hope you guys want to help me Smile .
I've got my website with a inline(width=210 height=210) frame in the inline frame are some links but when you on one of these links it will open the whole page in to this small inline frame, but it needs to open the whole page and not into the inline frame. I know you got target="_blank" but it should not open a new window Big Grin.

Thx a lot in advance.
Try target="_parent" or target="_top".
how can i change the time from gmt(using the code in post #23, http://community.mybboard.net/showthread...1#pid24911)?
Michael83 Wrote:Try target="_parent" or target="_top".

target="_parent" Works

Thx a lot m8
Pages: 1 2 3 4 5 6 7 8 9 10 11 12