MyBB Community Forums

Full Version: Displaying News on your 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 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
Oops, I had search and subject the wrong way around (that'll teach me to read the PHP documentation better):

$subject = str_replace('[ARMA]', '', $row['subject']);
[Image: notworthy.gif] Fantastic! You've made me very happy MrD. Smile Everything works now. Awesome!
(2009-01-31, 12:08 AM)MCII-Totality Wrote: [ -> ]Out of curiosity, How can I get maybe 30 characters of the announcement

You can use PHP's substr function to cut down the length of the message string:

$message = $parser->parse_message($row2['message'], $options);
$message = substr($message, 0, 30);
Uhh... the avatar thing fails to work.

I did this:
{$row2['avatar']}
As you said.
You have to do an extra query to get it from the users table:
$query3 = $db->simple_select('users', 'avatar', "uid='{$row2['uid']}'");
$row3 = $db->fetch_array($query3);

Then you can use:
{$row3['avatar']}

The bit at the top needs to go inside the loop:
while($row = $db->fetch_array($query))

And after:
$query2 = $db->simple_select('posts', '*', "pid='{$row['firstpost']}'");
$row2 = $db->fetch_array($query2);
I am not good at PHP. Can you explain like... the order and everything again because I did not get it.
(2009-01-31, 12:41 PM)MrD. Wrote: [ -> ]
(2009-01-31, 12:08 AM)MCII-Totality Wrote: [ -> ]Out of curiosity, How can I get maybe 30 characters of the announcement

You can use PHP's substr function to cut down the length of the message string:

$message = $parser->parse_message($row2['message'], $options);
$message = substr($message, 0, 30);

What else should be with this? the rest of whats on the first post or less?
i Get this error i am using V1.4.4Fatal error: Call to undefined method MyBB::simple_select() in http://localhost/news.php on line 2

Here is the code for News.php
<?php
    $query = $mybb->simple_select(TABLE_PREFIX.'threads', '*', "fid='{$fid}' ORDER BY tid DESC LIMIT {$limit}");
    if($mybb->num_rows($query) > 0)
    {
        while($row = $mybb->fetch_array($query))
        {
            $query2 = $mybb->simple_select(TABLE_PREFIX.'posts', '*', "tid='{$row['tid']}' LIMIT 1");
            $row2 = $mybb->fetch_array($query2);
            
            $date = my_date($mybb->settings['dateformat'], $row2['dateline'], "", 1);
            $time = my_date($mybb->settings['timeformat'], $row2['dateline'], "", 1);

            $options = array(
                            'allow_html' => 'yes',
                            'filter_badwords' => 'yes',
                            'allow_mycode' => 'yes',
                            'allow_smilies' => 'yes',
                            'nl2br' => 'yes',
                            'me_username' => 'yes'
                            );
            $message = $parser->parse_message($row2['message'], $options);
            
            echo("<a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">{$row['subject']}</a> -
                Posted: {$date} {$time} by <a href=\"{$forumpath}member.php?action=profile&uid={$row2['uid']}\">{$row2['username']}</a><br />");
            echo("{$message}<br /><br />");
            echo("Replies (<a href=\"{$forumpath}showthread.php?tid={$row['tid']}\">{$row['replies']}</a>)<br /><hr />");
        }
    }
    else
    {
        echo 'Nothing to display.';
    }

?>
I think all the
$mybb->
need to be replaced with
$db->
Tried but nothing show up.

Can you please provide me code for news.php & newsheader.php ll be a great help.


EDIT: i re-created file now i get this error
MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
    1146 - Table 'kdbb.mybb_mybb_threads' doesn't exist
Query:
    SELECT * FROM mybb_mybb_threads WHERE fid='2' ORDER BY tid DESC LIMIT 5
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33