2009-11-15, 11:11 AM
I've made my own shoutbox but I've got a bit of a problem, it doesn't show all shouts, I've got an alternating row colour function in it, and basically if you have say 3 shouts in the database, only two shouts will display, Here's my shoutbox code, I would love some help with this.
If I remove all the alt colour coding, it displays all the shouts, this is fully working, I just need to keep the alt row colours and display all shouts
<?php
define("IN_MYBB", 1);
require "./global.php";
if($mybb->input['action'] == "update")
{
$query = $db->query("SELECT uid, avatar, username, message FROM ".TABLE_PREFIX."shoutbox ORDER BY id DESC LIMIT 20");
eval("\$shoutbox_shouts= \"".$templates->get("shoutbox_shouts")."\";");
output_page($shoutbox_shouts);
while($row = mysql_fetch_array($query))
{
// Displays alternate table row colors
function row_color($i){
$bg1 = "#1B1B1B"; // color one
$bg2 = "#0d0d0d"; // color two
if ( $i%2 ) {
return $bg1;
} else {
return $bg2;
}
}
echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
for( $i = 0; $i < $row = mysql_fetch_array($query); $i++){
echo "<tr><td width=\"2%\" bgcolor=".row_color($i)."><img src=\"".$row['avatar']."\" height=\"30\" width=\"30\" /></td><td width=\"98%\" bgcolor=".row_color($i)."> <a href=\"".$mybb->settings['bburl']."/member.php?action=profile&uid=".$row['uid']."\">".$row['username']."</a><img src=\"".$theme['imgdir']."/bullet.gif\" />".$row['message']."</td></tr>";
}
echo "</table>";}
}
if($mybb->input['action'] == "insert")
{
$query = $db->query("INSERT INTO ".TABLE_PREFIX."shoutbox(uid, avatar, username, message) VALUES ('".$mybb->user['uid']."', '".$mybb->user['avatar']."', '".$mybb->user['username']."', '".$_POST['message']."');",mysql_real_escape_string(strip_tags($message)));
}
?>
If I remove all the alt colour coding, it displays all the shouts, this is fully working, I just need to keep the alt row colours and display all shouts