I was wondering only how to show the first post in a forum. Similar to the way this site does it. Show the intial question and the user will have to click on the topic to be able to view all the replies. I got the code working so that it updates with the same ID so the replies go under the right topic but I can't get it so that it only shows the intiail topic.
I would also like for it to display in the right order, as of now it displays the most current entry first instead of the original entry at the top like on this site. I'm not sure how to do this with how I wrote my queries. All help is appreciated. Thanks in advance.
Here is the code that I currently use to display the results.
$query = "SELECT email FROM forum";
$result = mysql_query($query);
$email = "Select email from forum";
$resultemail = mysql_query($email);
$name = "Select name from forum";
$resultname = mysql_query($name);
$title = "Select title from forum";
$resulttitle = mysql_query($title);
$time = "Select times_viewed from forum";
$resulttime = mysql_query($time);
$response = "Select response from forum";
$resultresponse = mysql_query($response);
$timestamp = "Select timestamp from forum";
$resulttimestamp = mysql_query($timestamp);
$entry = "Select entry_num from forum";
$resultentry = mysql_query($entry);
echo "<font size=\"+2\"><b>Welcome</b></font>";
echo "<br>";
echo "<img src=\"http://www.website.com/images/image.jpg\" width=\"272\" height=\"214\">";
echo "<table border=\"1\">";
echo "<tr>";
echo "<td align=\"center\">Poster</td>";
echo "<td align=\"center\">Title</td>";
echo "<td align=\"center\">Times Viewed</td>";
echo "<td align=\"center\">Responses</td>";
echo "<td align=\"center\">Time of Entry</td>";
echo "</tr>";
if (mysql_num_rows($result) > 0) {
for ($i = 0; $i<mysql_num_fields($resultemail); $i++) {
if (mysql_field_name($resultemail, $i)=="email"){
$hyperLinkID = $i;
}
}
}
if (mysql_num_rows($result) > 0) {
for ($j = 0; $j<mysql_num_rows($result); $j++) {
echo "<tr>\n";
for ($k = 0; $k<mysql_num_fields($result); $k++) {
if($k==$hyperLinkID){
echo "<td align=center>". mysql_result($resultname,$j,$k) ."</td>\n";
echo "<td align=center><a href=\"board.php?command=display&id=" . mysql_result($resultentry,$j,$k) . "\">". mysql_result($resulttitle,$j,$k) ."</a></td> \n";
echo "<td align=center>" . mysql_result($resulttime, $j, $k) . "</td>\n";
echo "<td align=center>" . mysql_result($resultresponse, $j, $k) . "</td>\n";
echo "<td align=center>" . mysql_result($resulttimestamp, $j, $k) . "</td>\n";
} else {
echo "<td align=center>" . mysql_result($result, $j, $k) . "</td>\n";
}
}
echo "</tr>\n\n";
}
}
echo "</table>";