Cita:
Creo que mi error esta en la consulta pero no se como resolverlo. Les dejo el código para que me ayuden:Foros del Web -> PHP -> Tema que estoy viendo
Código PHP:
function ShowAllThemes(){
$query = "SELECT * FROM categorias_forum WHERE activo<>0 ORDER BY orden_de_presentacion ASC";
$result = mysql_query($query) or die("No se ha podido ejecutar la consulta: ".$query.". MySQL ha dicho: ".mysql_error());
if(!isset($_GET['tema'])){
echo "<table width='100%' border='0' cellpadding='0' cellspacing='1' bordercolor='#003366' class='table'>
<tr><td width='62%' class='txt forotema' style='padding-left:5px; padding-right:3px; padding-top:2px; padding-bottom:2px;'>Foro</td>
<td width='11%' class='forotema center'>Mensajes</td>
<td width='8%' class='forotema center'>Temas</td>
<td width='19%' class='forotema center'>Último mensaje </td></tr>";
while($fetch=mysql_fetch_assoc($result)){
echo "<tr><td colspan='4' class='txt forotema' style='padding-left:5px; padding-right:3px; padding-top:2px; padding-bottom:2px;'>".$fetch['titulo']."</td>
</tr><tr><td colspan='4' class='txt'>";
ShowAllTopics($fetch['idcat']);
echo "</td></tr>";
}
echo "</table>";
}else{
ListAllThemesForThisForo($_GET['tema']);
}
}
function ShowAllTopics($idcat){
$query = "SELECT * FROM forum WHERE activo<>0 AND idcat='".$idcat."' ORDER BY idcat ASC";
$result = mysql_query($query) or die("No se ha podido ejecutar la consulta: ".$query.". MySQL ha dicho: ".mysql_error());
echo "<table width='100%' border='0' cellpadding='0' cellspacing='1' bordercolor='#003366'>";
while($fetch=mysql_fetch_assoc($result)){
echo "<tr>
<td width='27' class='txt td' style='padding-left:5px; padding-right:3px; padding-top:2px; padding-bottom:2px;'><div align='center'><a href='foros.php?accion=mostrar&tema=".$fetch['idforo']."&ordenar=fecha&usuario=".$_SESSION['nombre']."&tipo=".$_SESSION['tipo']."&".SID."'><img src='images/forum/topics.gif' width='19' height='19' alt='Forum ".$fetch['nombre']."' border='0'></a></div></td>
<td width='595' class='txt td' style='padding-left:5px; padding-right:3px; padding-top:2px; padding-bottom:2px;'><a href='foros.php?accion=mostrar&tema=".$fetch['idforo']."&ordenar=fecha&usuario=".$_SESSION['nombre']."&tipo=".$_SESSION['tipo']."&".SID."'>".$fetch['nombre']."</a></td>
<td width='109' class='txtcn td'>".$fetch['post']."</td>
<td width='81' class='txtcn td'>".$fetch['temas']."</td>
<td width='190' class='txtcn td'>".$fetch['lastpost']."</td>
</tr>
<tr>
<td colspan='5' class='txt td' style='padding-left:5px; padding-right:3px; padding-top:2px; padding-bottom:2px;'>".$fetch['descripcion']."</td>
</tr>";
}
echo "</table>";
}
function ListAllThemesForThisForo($idforo){
$query = "SELECT post.*, postt.*, temas.*, user.*, foro.nombre AS nombre FROM post post, post_text postt, temas temas, users user, forum foro WHERE foro.idforo='".$idforo."' AND post.idpost=postt.idpost AND post.idtema=temas.idtema AND post.idusuario = user.iduser AND post.idforo='".$idforo."' AND temas.idforo='".$idforo."' ORDER BY post.idpost";
$result = mysql_query($query) or die("No se ha podido ejecutar la consulta: ".$query.". MySQL ha dicho: ".mysql_error());
echo "<table width='100%' border='0' cellpadding='0' cellspacing='1' class='table'>";
if(!isset($_GET['post']) || $_GET['post']!='newpost'){
echo "<tr><td colspan='6' class='forotema'><a href='foros.php?accion=mostrar&temas=todos&usuario=".$_SESSION['nombre']."&tipo=".$_SESSION['tipo']."&".SID."'>Foro</a> :: ".$fetch['nombre']."</td></tr>
<tr>
<td colspan='2'><div align='center' class='forotema center'>Temas</div></td>
<td width='13%' class='forotema center'>Respuestas</td>
<td width='14%' class='forotema center'>Autor</td>
<td width='9%' class='forotema center'>Lecturas</td>
<td width='17%' class='forotema center'>Última respuesta</td></tr>";
if(mysql_num_rows($result)!=0){
while($fetch=mysql_fetch_assoc($result)){
echo "<tr><td width='2%' class='td'><div align='center'><img src='images/forum/topics.gif' width='19' height='19'></div></td>
<td width='45%' class='txt td'>".$fetch['asunto']."</td><td class='txtcn td'>".$fetch['respuestas']."</td>
<td class='txtcn td'>".$fetch['login']."</td><td class='txtcn td'>".$fetch['respuestas']."</td>
<td class='txtcn td'>".$fetch['last_post_id']."</td></tr>";
}
}else{
echo "<tr><td colspan='6' class='td txtcn'>No hay temas en este Foro para mostrar</td></tr>";
}
}
echo "<tr><td colspan='6' class='td'> </td></tr><td colspan='6' class='td txtcn'><div align='left'>";
if(!isset($_GET['post']) || $_GET['post']!='newpost'){
echo "<form action='foros.php?accion=mostrar&tema=".$_GET['tema']."&usuario=".$_SESSION['nombre']."&tipo=".$_SESSION['tipo']."&post=newpost&".SID."' method='post' name='new_post' id='new_post'><input name='new_post' type='submit' class='btn' id='new_post' value='Nuevo Tema'>
</form>";
}elseif(isset($_GET['post']) && ($_GET['post']=="newpost")){
MakeFormTheme();
}
echo "</div></td>
</tr><tr><td colspan='6' class='td txtcn'><table width='200' border='0' align='right' cellpadding='0' cellspacing='1'>
<tr><td width='32'><img src='images/forum/announce.gif' alt='Anuncio global' class='hand'></td>
<td width='66' class='txt'>Anuncio</td><td width='28'><img src='images/forum/old-temas.gif' alt='Temas viejos' class='hand'></td>
<td width='74' class='txt'>Tema viejo </td></tr><tr>
<td><img src='images/forum/postit.gif' class='hand'></td>
<td class='txt'>PostIt</td><td><img src='images/forum/close-tema.gif' alt='Tema cerrado' class='hand'></td>
<td class='txt'>Tema cerrado </td></tr><tr>
<td><img src='images/forum/nuevo-tema.gif' alt='Temas nuevos' class='hand'></td>
<td class='txt'>Tema nuevo </td><td> </td><td> </td></tr></table></td></table>";
}
Código PHP:
<? ShowAllThemes(); ?>
![Negando](http://static.forosdelweb.com/fdwtheme/images/smilies/negar.gif)