What I've done is made a news table and then combined the shoutbox to work as a comment feature for the news. But the problem I'm having is that all the news entries won't show. Only one will show but the shoutbox does show under the one entry.
PHP Code:
<?php
include("inc/functions.php");
include("inc/bbcode.php");
//***************//
// START SCRIPT //
//***************//
$article_content .= "<A NAME='top'>";
mysql_connect("localhost", "---", "---") or die(mysql_error());
mysql_select_db("---_adopts") or die(mysql_error());
$result = mysql_query("SELECT * FROM news ORDER BY id DESC")
or die(mysql_error());
$article_title .= "News Den";
$article_content .= "<div id='news'>";
while($row = mysql_fetch_array( $result )) {
// Print out the contents of the entry
$article_content .= "<table class='news'><tr><td colspan='2'>".$row['date']."</td></tr>";
$article_content .= "<tr><td width='90px'><center><img src='http://www.freefever.com/freeclipart/clipart/newspaper2.gif' height='50px' width='50px'><br>SilverDragonTears<br><i><span style='font-size:10px; color:red'>Administrator</span></i></center></td><td>".$row['news']."<br><br><div class='enclosecomments'>";
$query = "SELECT * FROM ".$prefix."shoutbox ORDER BY id DESC LIMIT 0, 10";
$result = mysql_query($query);
$num = mysql_numrows($result);
//Loop out code
$i=0;
while ($i < $num) {
$id=@mysql_result($result,$i,"id");
$user=@mysql_result($result,$i,"user");
$date=@mysql_result($result,$i,"date");
$nolinecomment=@mysql_result($result,$i,"comment");
$nolinecomment = bbconvert($nolinecomment);
$comment=nl2br($nolinecomment);
$commentdiv = "<div class='comment' style='width:94%;padding:2%;background-color:aliceblue;margin-bottom:5px;'><div class='userdate' style='width:50%;height:25px;color:red;'>".$user." - ".$date."</div>".stripslashes($comment)."</div>";
$article_content = $article_content.$commentdiv;
$i++;
}
$article_content = $article_content."</div><p>Post a comment!</p>";
$article_content = $article_content."<form action='news.php' method='post'>
<textarea rows='5' cols='60' name='comment' wrap='physical' ></textarea><br>
<input type='submit' /></form>";
//here the user posts a comment
$comment = $_POST["comment"];
if ($comment != "") {
$date = date("Y-m-d H:i:s");
// $date = "10-23-3 21:02:35";
$user = $loggedinname;
if ($isloggedin!="yes") {
$user = "Guest";
}
$comment = $comment;
mysql_query("INSERT INTO ".$prefix."shoutbox VALUES ('', '$user', '$date', '$comment')");
$article_content = $article_content."<p>Your comment has been posted. Click <a href='news.php'>here</a> to view it.</p>";
}
else {
$article_content = $article_content."Post a comment.";
}
$article_content .= "<div id='topbutton'><a alt='Back to Top' href='#bottom' title='Bottom'><img src='images/arrow_up_16red.png'></a><a alt='Down' href='#top' title='Top'><img src='images/arrow_up_16.png'></a></div></tr></td></table>";
}
$article_content .= "</div>";
//***************//
// OUTPUT PAGE //
//***************//
echo showpage($article_title, $article_content, $date);
?>
<A NAME="bottom">