I'm using pure php for the moment and I'm having a problem on what to do next
using the command DESCRIBE
calls all the header of my database but I cannot call those
datas under the headers I have to manually put it.
What I want to know is:
- Can I populate the Table data automatically?
- How should I do the coding?
- Is there any tutorials for that?
This is my code so far:
<table class="table">
<tr>
<?php
$sql = "DESCRIBE `employee`";
$query = $conn->query($sql);
while ($row = $query->fetch()) {
?>
<th><?= $row['Field']; ?></th>
<?php } ?>
</tr>
<?php
$sql_datas = "SELECT * From `employee` ";
$query = $conn->query($sql_datas);
while ($row_data = $query->fetch()) {
?>
<tr>
<td><?= $row_data['id'] ?></td>
<td><?= $row_data['last_name'] ?></td>
<td><?= $row_data['given_name'] ?></td>
<td><?= $row_data['middle_name'] ?></td>
<td><?= $row_data['name'] ?></td>
</tr>
<?php } ?>
</table>