Skip to content

Instantly share code, notes, and snippets.

@Kingo4luv
Created February 23, 2018 21:52
Show Gist options
  • Save Kingo4luv/33c690805180c1b32e8a558f513ecf7d to your computer and use it in GitHub Desktop.
Save Kingo4luv/33c690805180c1b32e8a558f513ecf7d to your computer and use it in GitHub Desktop.
This file retrieve data from database and Display on the table
<?php
include 'init.php';
$sql = "SELECT * FROM users";
$results = $link->query($sql);
?>
<html>
<head>
<title>Retrieving From Database</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<br>
<div class="container">
<h4>The table below shows an example of Displaying database data inside a table</h4>
<table class="table">
<thead class="thead-dark">
<tr>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Username</th>
<th scope="col">Email</th>
</tr>
</thead>
<tbody>
<?php
while($userInfo = mysqli_fetch_assoc($results)):
?>
<tr>
<td><?php echo $userInfo['first_name'] ;?></td>
<td><?php echo $userInfo['last_name'] ;?></td>
<td><?php echo $userInfo['username'] ;?></td>
<td><?php echo $userInfo['email'] ;?></td>
</tr>
<?php endwhile ;?>
</tbody>
</table>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment