There is a table in which the alias field by which the output is sorted. It is necessary to display entries on a specific alias in three places in order not to make a request three times, how to make one?

 $query = "SELECT * FROM table"; $res = mysqli_query($connection, $query); $array=array(); while($row = mysqli_fetch_assoc($res)){ $array[$row['alias']][] = $row; } 

and then I do not know how to display entries by alias

  • four
    so what's the problem? the $array already has all the records broken by alias , it remains to output them: foreach ($array[$YOUR_ALIAS] as $row) {...} . Before the loop, checking for the presence of the $YOUR_ALIAS - BOPOH
  • thanks, it worked) - LLIAKAJI
  • one
    @BOPOH, please post your comment back. Perhaps your decision will help someone else. - Dmitriy Simushev

1 answer 1

Reply from comments

The $array already has all the records broken by alias , it remains to output them:

 if(isset($YOUR_ALIAS)) { foreach ($array[$YOUR_ALIAS] as $row) { ... } }