Tengo hechas 3 tablas:
CATEGORIAS (id_categoria, nombre, descripcion),
TEMAS (id_tema, descripcion, categoria, autor, fecha),
MENSAJES (id_mensaje, mensaje, categoria, tema, acutor, fecha).
Con este codigo me sale en todos los temas el numero total de mensajes que hay en esa categoría, pero lo que quiero sacar es dentro de esa categoría los que hay por cada tema.
Ayudaaaaa
Código PHP:
<?php require_once('Connections/foro.php'); ?>
<?php
$maxRows_temas = 20;
$pageNum_temas = 0;
if (isset($_GET['pageNum_temas'])) {
$pageNum_temas = $_GET['pageNum_temas'];
}
$startRow_temas = $pageNum_temas * $maxRows_temas;
$colname_temas = "-1";
if (isset($_GET['cat'])) {
$colname_temas = $_GET['cat'];
}
mysql_select_db($database_foro, $foro);
$query_temas = sprintf("SELECT * FROM temas WHERE categoria = %s", GetSQLValueString($colname_temas, "int"));
$query_limit_temas = sprintf("%s LIMIT %d, %d", $query_temas, $startRow_temas, $maxRows_temas);
$temas = mysql_query($query_limit_temas, $foro) or die(mysql_error());
$row_temas = mysql_fetch_assoc($temas);
if (isset($_GET['totalRows_temas'])) {
$totalRows_temas = $_GET['totalRows_temas'];
} else {
$all_temas = mysql_query($query_temas);
$totalRows_temas = mysql_num_rows($all_temas);
}
$totalPages_temas = ceil($totalRows_temas/$maxRows_temas)-1;
?>
// Y dentro del BODY.
<table class="table_foros" width="950" align="center">
<tr>
<td colspan="2" bgcolor="#000033"><img src="imagenes/48x5px.png" width="48" height="5" />TEMAS</td>
<td width="120" align="center" bgcolor="#000033">PUBLICACIONES TOTALES</td>
<td width="150" align="center" bgcolor="#000033">AUTOR</td>
<td width="100" align="center" bgcolor="#000033">FECHA</td>
</tr>
<?php do { ?>
<?php
mysql_select_db($database_foro, $foro);
$publicacion_sql = "SELECT * FROM mensajes WHERE tema ".$row_temas['id_temas'];
$pTotales = mysql_query($publicacion_sql) or die (mysql_error());
?>
<tr>
<td width="45" align="center"><img src="imagenes/folder.png" width="40" height="40" /></td>
<td width="389" align="center"><span class="table_foros_fechas"><?php echo $row_temas['descripcion']; ?></span><br /></td>
<td align="center"><span class="table_foros_fechas"><?php echo mysql_num_rows($mTotales); ?></span></td>
<td align="center"><span class="table_foros_autores"><?php echo $row_temas['autor']; ?></span></td>
<td align="center"><span class="table_foros_fechas"><?php echo $row_temas['fecha']; ?></span></td>
</tr>
<?php } while ($row_temas = mysql_fetch_assoc($temas)); ?>
</table>