I do have associative array in php (id,orderType,details) as in specified sequence.
I want to display this details in html table at runtime [while page loading]
How to achieve this? I have never done anything like this before,so please guide me. Thanks!
echo '<table>';
foreach($yourarray as $row){
echo '<tr>';
foreach($row as $key=>$cell){
echo '<td>'.$cell.'</td>';
}
echo '</tr>';
}
echo '</table>':
<table>
<tr>
<td>Id</td>
<td>Order</td>
<td>Type</td>
<td>Details</td>
</tr>
<?php
$your_array = array( array('id' => 12, 'order'=>1233, 'type'=> 1233, 'details'=>2444),
array('id' => 1, 'order'=>14, 'type'=> 444, 'details'=>88));
foreach($your_array as $row){ ?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['order']; ?></td>
<td><?php echo $row['type']; ?></td>
<td><?php echo $row['details']; ?></td>
</tr>
<?php } ?>
</table>
//detail() is your assosicative array
echo '<table><tr>';
echo '<td>id</td><td>orderType</td><td>details</td>';
echo '</tr>';
foreach($detail as $row){
echo '<tr>';
echo '<td>'.$row['id'].'</td>';
echo '<td>'.$row['orderType'].'</td>';
echo '<td>'.$row['details'].'</td>';
echo '</tr>';
}
echo '</table>';
$headerFlag = false;
$result = "<table border='2'>";
foreach ($array as $row){
$result = $result."<tr>";
if($headerFlag == false){
foreach($row as $key => $cell){
$result = $result."<th>".$key."</th>";
}
$headerFlag = true;
$result = $result."</tr>";
}
foreach($row as $key => $cell){
$result = $result."<td>".$cell."</td>";
}
$result = $result."</tr>";
}
echo $result = $result."</table>";