Hola a todos!!
e generado una tabla con php y myadmin(base de datos) para crear un foro en cada fila hay un tema y quiero que al clickar en cualquiera de las filas envie el respectivo id de cada tema a otro php para que muestre todas las respuestas.
Aqui teneis el código y lo que he intentado:
foro.php //la conexion ya está creada <?php //hilos más recientes $sql="SELECT * FROM foro ORDER BY fecha DESC"; $resultado=mysql_query($sql) or die("ERROR:imposible ejecutar la consulta.<br/>".mysql_error());
echo " <table class='tab'> <tr class='primera fila' ><th width='550px'>Hilo</th><th width='70px'>Autor</th><th wifth='100px'>Respuestas</th><th width='150px'>Fecha</th></tr>"; $contador=0; while ($fila=mysql_fetch_array($resultado)) { if($contador>=10)break; $id=$fila['id']; echo "<tr value='".$id."' onclick='roma(this)'>"; echo "<td>".$fila['titulo']."</td><td>".$fila['autor']."</td><td>".$fila['respuestas']."</td><td>".$fila['fecha']."</td>"; echo "</tr>"; $contador++; } echo '</table>'; ?>
Fichero.js function roma(objeto){ var id=objeto.value; document.location.href='foro_roma.php?id='+ id +''; }
foro_roma.php <?php $id=$_GET['id']; echo "$id"; $sql="select * from foro where id=".$id; $sql_respuestas="SELECT * FROM foro where identificador=".$id." ORDER by fecha DESC"; $resultado=mysql_query($sql) or die("ERROR:imposible ejecutar la consulta1.<br/>".mysql_error()); $respuesta2=mysql_query($sql_respuestas) or die("ERROR:imposible ejecutar la consulta2.<br/>".mysql_error()); while ($row=mysql_fetch_array($resultado)){
echo"<h2> <tr><td>". $row['titulo']."</td> </tr></h2> <table> <tr><td>Autor: ". $row['autor']."</td></tr> <tr><td>". $row['mensaje']."</td></tr> </table>"; echo"<br /><br /><a href=formulario.php?id=$id&respuestas=$respuestas>Responder</a><br /> <br />"; } ?>
ya se que puedo hacer botones y enlaces para no complicarme.... si no hay mas remedio creare un formulario con un input
salu2 a todos
|