Cita:
Iniciado por papoilazita
Buenas Noches!!
Tengo el seguiente problema: He probado primero la consulta en mysql y me retorno 2 lineas de resultados, al pasar para el codigophp no me imprime nada de los resultados que deberian ser dos lineas en la tabla
He hecho um print de nº lineas con $lineas=mysql_num_rows($result) y me sale 2 tambien que és el correcto:
dejo el codigo:
Código PHP:
$result = mysql_query("Select Li.Titol, Li.Tema , Le.ID From llibres Li Inner join Ejemplares e On Li.REF = e.REF Inner join Lectors Le On e.ID = Le.ID Where e.ID='1'");
echo "<table border='1' >";
echo"<tr>"
echo"<th>Titol</th>";
echo "<th>Autor</th>";
echo"</tr>";
$titol=($row['Titol']);$autor=($row['Autor']);$id=($row['ID']);
while ($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $titol . "</td>";
echo "<td>" . $autor . "</td>";
echo "</tr>";
}
echo "</table>";
Me podeis decir que estoy haciendo mal ...
Agradezco por adelantado la ayuda. Muchas gracias,
Cita:
Iniciado por Vun
Prueba asi, solo movi una linea de lugar:
Código PHP:
$result = mysql_query("Select Li.Titol, Li.Tema , Le.ID From llibres Li Inner join Ejemplares e On Li.REF = e.REF Inner join Lectors Le On e.ID = Le.ID Where e.ID='1'");
echo "<table border='1' >";
echo"<tr>"
echo"<th>Titol</th>";
echo "<th>Autor</th>";
echo"</tr>";
while ($row = mysql_fetch_array($result))
$titol=($row['Titol']);$autor=($row['Autor']);$id=($row['ID']);
{
echo "<tr>";
echo "<td>" . $titol . "</td>";
echo "<td>" . $autor . "</td>";
echo "</tr>";
}
echo "</table>";
Hola papoilazita y Vun.
Mas bien el script quedaria de la siguiente manera:
Código PHP:
$result = mysql_query("Select Li.Titol, Li.Tema , Le.ID From llibres Li Inner join Ejemplares e On Li.REF = e.REF Inner join Lectors Le On e.ID = Le.ID Where e.ID='1'");
$html = "
<table border='1' >
<tr>
<th>Titol</th>
<th>Autor</th>
</tr>";
while ($row = mysql_fetch_array($result))
{
$html .= "
<tr>
<td>
{$row['Titol']}
</td>
<td>
{$row['Autor']}
</td>
</tr>
";
}
$html .= "</table>";
echo $html;
Cualquier cosa nos lo comentas. Saludos!!!