Código PHP:
if(isset($_GET['action']) && $_GET['action']!="newpost" && !isset($_GET['topic']) && !isset($_GET['what'])){
# Obtenemos el título del Foro actual
$query = "SELECT * FROM foros WHERE idcat='".$_GET['catforo']."' AND idforo='".$idforo."'";
$result = mysql_query($query) or die("No se ha podido ejecutar la consulta ".$query.". Error: ".mysql_error());
$fetch = mysql_fetch_assoc($result);
echo "<table width='100%' border='0' cellpadding='0' cellspacing='1' class='table'>
<tr><td colspan='6' class='forotema' style='padding-right:3px; padding-left:5px; padding-top:1px; padding-bottom:1px'><a href='foros.php?action=show&foro=all&".SID."'>Foro</a> :: <a href='foros.php?action=show&catforo=".$fetch['idcat']."&foro=".$fetch['idforo']."&".SID."'>".$fetch['title']." </td>
</tr><tr>
<td colspan='2'><div align='center' class='forotema left' style='padding-right:3px; padding-left:3px; padding-top:1px; padding-bottom:1px'>Temas</div></td>
<td width='11%' class='forotema center'>Respuestas</td><td width='11%' class='forotema center'>Autor</td>
<td width='10%' class='forotema center'>Lecturas</td><td width='19%' class='forotema center'>Última respuesta</td>
</tr>";
# Obtenemos los datos de la tabla
$query_00 = "SELECT * FROM post WHERE idcat='".$_GET['catforo']."' AND idforo=".$_GET['foro']."";
$result_00 = mysql_query($query_00) or die("No se ha podido ejecutar la consulta ".$query_00.". Error: ".mysql_error());
if(mysql_num_rows($result_00)!=0){
while($fr = mysql_fetch_assoc($result_00)){
# Consulta que me devuelve la cantidad de respuestas de ese post, así como la fecha de la última respuesta
$query_01 = "SELECT count(idreply) as replycant,date,DAYOFMONTH(date) AS dia, DAYOFWEEK(date) AS semana, MONTH(date) AS mes, YEAR(date) AS year, DATE_FORMAT(date,'%h:%i %p') AS hora from reply where idpost='".$fr['idpost']."' group by idpost order by date ASC";
$result_01 = mysql_query($query_01) or die("No se ha podido ejecutar la consulta ".$query_01.". Error: ".mysql_error());
$fr_01 = mysql_fetch_assoc($result_01);
# Consulta que me devuelve el usuario que posteo el mensaje
$query_02 = "SELECT us.iduser, us.login, ps.iduser, ps.idpost FROM users us, post ps WHERE ps.idpost=".$fr['idpost']." AND ps.iduser=us.iduser";
$result_02 = mysql_query($query_02) or die("No se ha podido ejecutar la consulta ".$query_02.". Error: ".mysql_error());
$fr_02 = mysql_fetch_assoc($result_02);
echo "<tr>
<td width='5%' class='td txtcn'>
<img src='images/forum/newtopics.gif' width='27' height='27'>
</td>
<td width='41%' class='td txt'><a href='foros.php?action=show&catforo=".$_GET['catforo']."&foro=".$_GET['foro']."&topic=".$fr['idpost']."&".SID."'><span class='info' title='".$fr['text']."'>".$fr['subject']."</span></a></td>
<td class='td txtcn'>".$fr_01['replycant']."</td><td class='td txtcn'>".$fr_02['login']."</td>
<td class='td txtcn'>".$fr['hits']."</td><td class='td txtcn'>";
MakeDate($fr_01['dia'], $fr_01['semana'], $fr_01['mes'], $fr_01['year'], $fr_01['hora']);
echo "</td>
</tr>";
}
}else{
echo "<tr><td class='td txt' colspan='6' style='padding-right:3px; padding-left:5px; padding-top:1px; padding-bottom:1px'>No hay mensajes en este Foro</td></tr>";
}
echo "<tr>
<td colspan='6' class='td txtcn'><div align='left' style='padding-right:3px; padding-left:5px; padding-top:1px; padding-bottom:1px'>
<form action='foros.php?action=newpost&catforo=".$fetch['idcat']."&foro=".$fetch['idforo']."&".SID."' method='post' name='form' id='form'>
<input name='newpost' type='submit' class='btn' id='newpost' value='Nuevo tema ...'>
</form></div></td></tr><tr>
<td colspan='6' class='td txtcn' style='padding-right:3px; padding-left:5px; padding-top:1px; padding-bottom:1px'><table width='200' border='0' align='left' cellpadding='0' cellspacing='2'>
<tr>
<td width='27'><div align='center'><img src='images/forum/announce.gif' width='27' height='27'></div></td>
<td width='62' class='txt'>Anuncio</td>
<td width='29'><div align='center'><img src='images/forum/oldtopics.gif' width='27' height='27'></div></td>
<td width='72' class='txt'>Tema viejo </td>
</tr><tr>
<td><div align='center'><img src='images/forum/postit.gif' width='27' height='27'></div></td>
<td class='txt'>PostIt</td>
<td><div align='center'><img src='images/forum/closetopics.gif' width='27' height='27'></div></td>
<td class='txt'>Tema cerrado </td>
</tr><tr>
<td><div align='center'><img src='images/forum/newtopics.gif' width='27' height='27'></div></td>
<td class='txt'>Tema nuevo </td>
<td><div align='center'></div></td>
<td> </td></tr></table></td></tr></table>";
}elseif($_GET['action']=="show" && (isset($_GET['topic']))){
PostDetails($_GET['topic']);
}elseif($_GET['action']=="newpost"){
FormReply();
}elseif($_GET['action']=="show" && isset($_GET['what']) && $_GET['what']=="aboutforos"){
AboutForo();
}