There is an array obtained from the database, with an unknown number of rows.

When prompted:

print_r($res) 

we get:

Array ([0] => Array ([id] => 1 [number] => 203 [loc] => Tech support [fio] => Sergey Zabuldygin) [1] => Array ([id] => 2 [number ] => 112 [loc] => Legal Department [fio] => Ivan Unfair] [2] => Array ([id] => 3 [number] => 115 [loc] => Drafts [fio] => Georgy Krivorukov))

How to deploy it to a table in a loop?

    2 answers 2

     echo '<table cellpadding="5" cellspacing="0" border="1">'; foreach ($res as $key => $value) { echo "<tr>"; foreach ($value as $data) echo "<td>".$data."</td>"; echo "</tr>"; } echo "</table>"; 

      Understood, thanks:

       echo "<table>"; foreach ($res as $result){ echo "<tr>"; foreach ($result as $rValue){ echo "<td>{$rValue}</td>"; } echo "</tr>"; } echo "</table>";