Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/03/2009, 03:02
elbastardo
 
Fecha de Ingreso: septiembre-2006
Mensajes: 141
Antigüedad: 18 años, 5 meses
Puntos: 1
Detalle en php y html para mostrar datos

Hola gente forera, tengo un drama con un if para poner mensajes como "Hay comentarios" (en una nota) o "no hay comentarios".
Es en la página principal donde muestro los títulos, una breve descripción y una fotito para cada noticia.
Si la nota tiene foto todo funciona perfecto y abajo 'avisa' si hay comentarios o no.
La cuestión es cuando la nota no tiene foto, muestra el título, la descripción pero se saltea si tiene comentarios o no.

No sé si me explico, muestro el código a ver si alguien me ilumina :P

Código PHP:

<td colspan="2">
<div id="siteInfo12">
<div align="left">
<SPAN STYLE="font-size:15px;font-family:Tahoma;color:#9B0000;font-weight:bold">
<a href="<?=$rowa['id_noticia']?>-<? echo "$tit"?>.html" onmouseover="status='Ampliar noticia'; return true" onmouseout="status=''">
<?=$rowa['titulo']?></a>
</SPAN>
</div> 
</div></td>
</tr>
<tr>

<td align="left" valign="top">
<div id="siteInfo12">
<div align="left">
<SPAN STYLE="font-size:11px;font-family:Tahoma;color:#666666">
<?php
$tex 
substr(strip_tags("$rowa[bajada]"), 0245);
$baja reemplazar$tex );
?>
<a href="<?=$rowa['id_noticia']?>-<? echo "$tit"?>.html" onmouseover="status='Ampliar noticia'; return true" onmouseout="status=''"><?php echo "$baja... (sigue)"?></a>
</SPAN>
</div> 
</div>

</td>
<? 
$sql_
="select imagen from imagenes where id_noticia='{$rowa['id_noticia']}' limit 1";
$resultado_=mysql_query($sql_,$link);
while (
$rowa_=mysql_fetch_array($resultado_))
{
$archivo="imagenes_noticia/";
$archivo.=$rowa_['imagen'];
if (
is_file($archivo))
{
?>
<td width="86" rowspan="4" align="left">



<div align="right">
<a href="<?=$rowa['id_noticia']?>-<? echo "$tit"?>.html" onmouseover="status='Ampliar noticia'; return true" onmouseout="status=''">
<img src="imagenes_noticia/chica_<?=$rowa_['imagen']?>" alt="<?=$rowa['leyenda']?>" width="120" border="0"></a>



</div>
</td>
<?
}
?>
</tr>

<!-- esta parte no la muestra si no hay foto -->

<tr>
<?
$id_noticia 
$rowa['id_noticia'];
$sql "SELECT COUNT(*) AS 'total' FROM comentarios WHERE id_noticia = '$id_noticia' AND aprobado = 1";
$res mysql_query($sql);
$row mysql_fetch_array($res);
?> 
<td align="left" valign="top">
<div id="siteInfo12">
<div align="left">
<SPAN STYLE="font-size:11px;font-family:Tahoma;color:#9B0000">

<?
$num 
$row['total'];
if (
$num == 1)
{echo 
"$num comentario";}

else if (
$num >= 2)
{echo 
"$num comentarios";}

else
{echo 
"No hay comentarios aún";}



?> 

</SPAN>
</div>
</div>
</td>
</tr>
<!-- hasta aca -->
<?php ?>
</table> 

<?php ?>
Quedó medio entreverado, espero alguien me ayude.
Salutes!