Search the database and display with while

Asked

Viewed 1,543 times

-5

Well in this case, my question is this, I select the database with the criteria I want you to have. How can I then do a while to show these results, which were fetched from the database.

Thank you.

  • Put in the code you have

  • I think it will be necessary while. Post the code you have already developed.

  • It depends on what your search code looks like. The only way to respond is by putting your code in.

2 answers

1


Would that be?

$query = "SELECT...";
$sql = mysqli_query($conexao, $query);

while($dado = mysql_fetch_array($sql)){ // Enquanto houver dados ficará em loop
   $a = $dado['coluna1']; //recupera o dado do array
   $b = $dado['coluna2'];
   echo $a."-".$b."<br><br>"; //exibe o dado
} 
  • By the way, what is mysql_fetch Assoc for?

  • 1

    @Gonçalo o fetch_assoc(), does the same thing as fetch_array(), the difference is that with the fetch_array() you can indicate the index of the query by the name of the database column or by the index number of the array, already the fetch_assoc(), is by column name only. Note that these functions are obsolete in PHP 7.

  • Tell me what the $variable given in the while parameter means

  • 1

    $dado is an array, it will receive the rows of your database table, every loop of the while she gets a new line

-1

  • 1

    Friend I know how to use the mysql fetch array functionality, I just don’t know how to show all the data of this select, because for example if I do a select Where ages="25", there may be various ages with 25 years and I want to show the data of these people all with ages equal to 25 years.

  • For what SELECT wants is set select where idades="25", I don’t understand

Browser other questions tagged

You are not signed in. Login or sign up in order to post.