Display data from MySQL table to you view table page using while loop is very simple. First select all record from MySQL table using MySQLi query and fetch data use mysqli_fetch_array or mysqli_fetch_assoc and display all data in table view page use while loop.
For Example:
Display data using mysqli_fetch_array() in PHP.
<table> <tr> <th>Name</th> <th>Email</th> <th>Phone</th> </tr> <?php $sql=mysqli_query($con,"SELECT * FROM Table Name"); while($row=mysqli_fetch_array($sql)){ ?> <tr> <td><?php echo $row[1]; ?></td> <td><?php echo $row[2]; ?></td> <td><?php echo $row[3]; ?></td> </tr> <?php } ?> </table>
Or Try It
Display data using mysqli_fetch_assoc() in PHP.
<table> <tr> <th>Name</th> <th>Email</th> <th>Phone</th> </tr> <?php $sql=mysqli_query($con,"SELECT * FROM Table Name"); while($row=mysqli_fetch_assoc($sql)){ ?> <tr> <td><?php echo $row["name"]; ?></td> <td><?php echo $row["email"]; ?></td> <td><?php echo $row["phone"]; ?></td> </tr> <?php } ?> </table>
Question and answer is powered by AnsPress.io