You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BY fecha DESC 1' at line 1
Resulta que estoy creando un pequeño foro que tiene 3 columnas, "Temas", "total de comentarios" y "ultimo comentario". Dentro de tema y total de comentarios ya logré que aparezcan los datos correspondientes, pero el problema es dentro de "ultimo comentario" donde abajito también aparecerá la fecha en que comentaron.
Este es código de la tabla:
Código:
SOLUCIONADO <table border="0" cellpadding="8" cellspacing="0" class="categorias"> <tr> <th>Temas</th> <th>Total de comentarios </th> <th>Ultimo comentario </th> </tr> <?php do { ?> <?php mysql_select_db($database_foro_cuc, $foro_cuc); $publicacion_sql = "SELECT id_mensaje FROM mensajes WHERE categoria = " . $row_foros['id_categoria']; $ultimosql = "SELECT autor, fecha FROM mensajes WHERE categoria = " . $row_foros['id_categoria'] . "ORDER BY fecha DESC LIMIT 1"; $uPost = mysql_query($ultimosql) or die(mysql_error()); $pTotales = mysql_query($publicacion_sql) or die (mysql_error()); ?> <tr> <td><a href="categorias.php?cat=<?php echo $row_foros['id_categoria']; ?>"><?php echo $row_foros['nombre']; ?></a> <p><?php echo $row_foros['descripcion']; ?></p></td> <td align="center"><?php echo mysql_num_rows($pTotales); ?></td> <td align="center"><?php $up = mysql_fetch_assoc ($uPost); echo $up['fecha']; echo '<br />'; echo $up['autor']; ?></td> </tr> <?php } while ($row_foros = mysql_fetch_assoc($foros)); ?> </table>