I'm trying to make a report by joining 3 tables. But the table is not being generated. The query works in PHPMYADMIN, but not in php.
PHPcode
$sql="SELECT fp_marca.marca as MarcaF,
fp_modelo.modelo as ModeloF,
fp_ano.combustivel as CombustivelF,
fp_ano.ano as AnoF,
fp_ano.valor as ValorF
FROM fp_ano
LEFT JOIN fp_modelo on fp_ano.codigo_modelo = fp_modelo.codigo_modelo
LEFT JOIN fp_marca on fp_modelo.codigo_marca = fp_marca.codigo_marca
ORDER BY fp_ano.codigo_fipe, fp_ano.ano";
$result = mysqli_query($sql) or die("error in query");
while ($row = mysql_fetch_array($result)) {
echo "<tr>
<td>" . $row['marca'] . "</td>
<td>" . $row['modelo'] . "</td>
<td>" . $row['combustivel'] . "</td>
<td>" . $row['ano'] . "</td>
<td>" . $row['valor'] . "</td>
</tr>";
}
Code Response
error in query