Log in

View Full Version : Modification Help


Kirk Y
05-25-2006, 07:07 PM
Okay, I've made a small modification to my forum that enables Administrators to post little blast messages. For example, some users don't browse the entire forum and might miss an important message about a clan war -- this will hopefully prevent that. It's basically a shoutbox, but all the shoutbox hacks I found here were too feature-full, I wanted something REALLY basic, just a quick form to post a message, that's it. So I've created a form and when submitted, the data is inserted into the sql db. I then created a plugin to pull the data from the db and then display the text on the forumhome page.

This is the plugin code I'm using:
switch (strtolower($vbulletin->config['Database']['dbtype']))
{
// load standard MySQL class
case 'mysql':
case '':
{
$db_temp =& new vB_Database($vbulletin);
break;
}
// load MySQLi class
case 'mysqli':
{
$db_temp =& new vB_Database_MySQLi($vbulletin);
break;
}
}

$blast = $db->query_first("SELECT * FROM blastmsg ORDER BY date DESC");

And this is the INSERT code I'm using:
$db->query_write("INSERT INTO blastmsg (user, message, date) VALUES
('$username', '$message', '$date')");

So, now that you hopefully understand what I'm trying to do here. Perhaps someone can answer a few issues I'm having.

First off, how can I wrap the message text to the next line? At the moment, it just increases the page width to fit the text. I'm using $blast[message] to post the user's message. I tried using a PHP wordwrap function, but couldn't get it to work -- is it possible to wrap an array?

Secondly, how can I post all rows in the table? At the moment, I've only been able to get it to post the most recent.

Finally, if anyone has an idea on improving efficiency with it, I'm all ears -- I'm rather new at creating hacks.

Thanks in advance for any help you guys can offer.