Why is only one table row selected here? And I need all the contents of the mail table.

  <?php $result = mysql_query("SELECT * FROM mail "); $r = mysql_fetch_array($result); ?> <table> <tr> <td>Имя</td> <td>Email</td> <td>Сообщение</td> </tr> <tr> <td><?php echo $r['name']; ?></td> <td><?php echo $r['email']; ?></td> <td><?php echo $r['messages']; ?></td> </tr> </table> 

    1 answer 1

     <?php $result = mysql_query("SELECT * FROM mail "); $r = array(); while($row = mysql_fetch_array($result)) { $r[] = $row; } ?> 

    you now have all the rows in the $ r array

     <table> <tr> <td>Имя</td> <td>Email</td> <td>Сообщение</td> </tr> <?php foreach($r as $row) : ?> <tr> <td><?php echo $row['name']; ?></td> <td><?php echo $row['email']; ?></td> <td><?php echo $row['messages']; ?></td> </tr> <?php endforeach; ?> </table>