How to create a table in PHP
How to create a table in PHP
1 Answer
It's easy to create a table in PHP
just you need to write your table structure then loop and fetch data into the table
Example table structure
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Age</th>
</tr>
</table>
some data to fetch
<?php
$myData = array(
1=>array('Firstname'=>'ahmad','Age'=>17),
2=>array('Firstname'=>'ali' ,'Age'=>15),
3=>array('Firstname'=>'wael' ,'Age'=>13),
);
?>
fetch data into table
<?php
$myData = array(
1=>array('Firstname'=>'ahmad','Age'=>17),
2=>array('Firstname'=>'ali' ,'Age'=>15),
3=>array('Firstname'=>'wael' ,'Age'=>13),
);
?>
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Age</th>
</tr>
<?php
foreach ($myData as $value) {
echo '<tr>
<td>'.$value['Firstname'].'</td>
<td>'.$value['Age'].'</td>
</tr>';
}
?>
</table>
answer Link