Ver Mensaje Individual
  #16 (permalink)  
Antiguo 06/02/2011, 12:27
Malekith
 
Fecha de Ingreso: abril-2006
Mensajes: 105
Antigüedad: 18 años, 10 meses
Puntos: 11
Respuesta: Mostrar a que tema pertenece un artículo determinado

Código PHP:
<div class="NewsItem"> 
                    <h2 class="NewsTitle"><font size="5">EVENTOS</font></h2><br><br> 
                    <table border="0" height="38" cellpadding="0" cellspacing="0"> 
    <tr> 
        <th height="16" align="left" valign="top"> 
        <p align="left"> 
        <img border="0" src="./images/resumen.jpg" height="24" align="left"></th> 
        <th height="16" align="left" valign="top"> 
        <p align="left"> 
        <img border="0" src="./images/tema.jpg" height="24" align="left"></th> 
        <th height="16" align="left" valign="top"> 
        <p align="left"> 
        <img border="0" src="./images/dia.jpg" height="24" align="left"></th> 
    </tr> 

<?php  
//conectamos a la base   
include('conexion.php'); 

//hacemos las consultas   
$result=mysql_query("select * from eventos order by fecha Desc"$connect);   
$row=mysql_fetch_array($result); 

$id_tema=$row[id_tema]; 
?> 
<? 

$result2
=mysql_query("SELECT * FROM temas where id_tema='$id_tema' ORDER BY RAND() LIMIT 1"$connect);  
$row2=mysql_fetch_array($result2);  

$imagen=$row2[imagen]; 

?> 
<?php  
//Recogemos las consultas en un array y las mostramos   
while($row=mysql_fetch_array($result))  
{  
   
echo 
'<tr> 
        <td height="19" valign="top" valign="top" background="./images/bg_eventos.jpg"> 
        <a href="index.php?seccion=evento&id='
.$row["id_evento"].'"> 
        <p align="left"><b> - '
.$row["titulo"].':</b><br><br>'.nl2br($row["resumen"]).'</a></td> 
        <td height="19" valign="top" background="./images/bg_eventos.jpg"> 
        <a href="index.php?seccion=evento&id='
.$row["id_evento"].'"> 
        <p align="center"><img border="0" src="'
.$imagen.'" width="50" height="70"></a></td> 
        <td height="19" valign="top" background="./images/bg_eventos.jpg"> 
        <a href="index.php?seccion=evento&id='
.$row["id_evento"].'"> 
        <p align="center"> - '
.$row["dia"].'</p> 
        </a> 
        </td> 
    </tr> 
    <tr> 
        <td height="5" valign="top" valign="top" background="./images/bg_eventos.jpg"> 
        </td> 
        <td height="5" valign="top" background="./images/bg_eventos.jpg"> 
        </td> 
        <td height="5" valign="top" background="./images/bg_eventos.jpg"> 
        </td> 
    </tr> 
'
;  
}  
 
mysql_free_result($result
?></table> 
                </div>
Al usar el rand me da error en la línea que defino la variable $row2, en la 29:

$row2=mysql_fetch_array($result2);

¿Ideas?