4
I am trying to perform a database query with the following script:
<?php
require("conexao.php");
$exibir = mysql_query("SELECT * FROM produtos");
while ($r = mysql_fetch_array($exibir)){
$id = $r['id'];
$nome = $r['nome'];
$altura = $r['altura'];
$peso = $r['peso'];
$imc = $r['imc'];
}
?>
<?php
echo "$nome <br/>";
?>
The code above was to return all table names, but only returns me the last !
I’d like to have all the names turned around!!
What is wrong?
Already started using obsolete functions and removed from new versions of PHP.
– rray
You’re looping the result, and in the end you’re displaying a variable, so it’s the last result because the loop rotated them all. The last thing added in
$nome
was the value of the last record.– Ricardo
that Samuel, use mysqli_query() and mysqli_fetch_array() as @rray quoted.
– DiChrist