message board problem
Posted: Mon Nov 14, 2005 2:17 pm
Ok I know I'm missing something small in here but I just can't figure out what it is. I am trying to dispaly the topics posted in my message board but I'm not getting anything. Here is my php code:
Can someone see what I'm missing?
Hawleyjr Edit: Username/Password removed.
Code: Select all
<? php
$conn = mysql_connect("mysql", "*****", "*****") or die(mysql_error());
mysql_select_db("alumni",$conn) or die(mysql_error());
$get_topics = "SELECT `topic_id`, `topic_title`, date_format(topic_create_time, '%b %e %Y at %r') as fmt_topic_create_time, `topic_owner` FROM `forum_topics` ORDER BY `topic_create_time` DESC";
$get_topics_res = mysql_query($get_topics,$conn) or die(mysql_error());
if (mysql_num_rows($get_topics_res) < 1) {
$display_block = "<table width=\"790px\"><tr><td align=\"center\"><p><font size=\"4\">No topics exist</font></p></td></tr></table>";
} else {
$display_block = "<table width=\"790px\" cellpadding=\"3\" cellspacing=\"1\"><tr><td width=\"80%\"><p><font size=\"4\">TOPIC TITLE</td><td width=\"20%\"># OF POSTS</td></tr>";
while ($topic_info = mysql_fetch_array($get_topics_res)) {
$topic_id = $topic_info['topic_id'];
$topic_title = stripslashes($topic_info['topic_title']);
$topic_create_time = $topic_info['fmt_topic_create_time'];
$topic_owner = stripslashes($topic_info['topic_owner']);
$get_num_posts = "SELECT count(post_id) FROM `forum_posts` WHERE `topic_id` = $topic_id";
$get_num_posts_res = mysql_query($get_num_posts,$conn) or die(mysql_error());
$num_posts = mysql_result($get_num_posts_res,0,'count(post_id)');
$display_block .= "<tr><td width=\"80%\"><a href=\"showtopic.php?topic_id=$topic_id\"><b>$topic_title</b></a><br>Created on $topic_create_time by $topic_owner</td><td width=\"20%\" align=\"center\">$num_posts</td></tr>";
}
$display_block .= "</table>";
}
?>
<html>
<head>
<title>Untitled</title>
</head>
<body text="#006633">
<?php echo "$display_block"; ?>
<p><a href="addtopic.htm">Add A Topic</a></p>
</body>
</html>Can someone see what I'm missing?
Hawleyjr Edit: Username/Password removed.