0

在 php (id,orderType,details)中确实有关联数组,就像指定的顺序一样。

我想在运行时在 html 表中显示此详细信息[页面加载时]

如何做到这一点?我以前从来没有做过这样的事情,所以请指导我。谢谢!

4

4 回答 4

0
<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>
于 2013-07-22T10:44:29.507 回答
0
echo '<table>';
foreach($yourarray as $row){
    echo '<tr>';
    foreach($row as $key=>$cell){
        echo '<td>'.$cell.'</td>';
    }
    echo '</tr>';
}
echo '</table>':
于 2013-07-22T10:40:22.663 回答
0
//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>';
于 2013-07-22T10:48:26.813 回答
0
$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>";
于 2013-12-10T11:39:47.753 回答