把页眉放在桌子的上面


Put header on top of the table

我需要将标题放在下面代码创建的表的顶部。表有9列。表是根据Shell脚本文本文件创建的。

$myfile = file_get_contents('/ftpfiles/monitor-data') or die ("Unable");    
$table = '<table border="2" width="100%" height="500" style="border-collapse: collapse; border: 3px solid #0000FF" bordercolorlight="#0000FF">';
$trimmed = trim($myfile);
$filearray = explode("'n", $trimmed);
foreach($filearray as $row) {
    // here separate your row that is a string, into an array
    $cols = explode(" ", $row);
    $table .= '<tr>';
    foreach($cols as $value) {
        $table .= '<td align = "center">'.$value.'</td>';
    }
    $table .= '</tr>';
}
$table .= '</table>';
echo $table;  

使用标签

    $myfile = file_get_contents('/ftpfiles/monitor-data') or die ("Unable");    
    $table = '<table border="2" width="100%" height="500" style="border-collapse: collapse; border: 3px solid #0000FF" bordercolorlight="#0000FF">';
$table.='<tr>
<th>Head1</th><th>Head2</th>...
</tr>';
    $trimmed = trim($myfile);
    $filearray = explode("'n", $trimmed);
    foreach($filearray as $row) {
        // here separate your row that is a string, into an array
        $cols = explode(" ", $row);
        $table .= '<tr>';
        foreach($cols as $value) {
            $table .= '<td align = "center">'.$value.'</td>';
        }
        $table .= '</tr>';
    }
    $table .= '</table>';
    echo $table;
$myfile = file_get_contents('/ftpfiles/monitor-data') or die ("Unable");    
$table = '<table border="2" width="100%" height="500" style="border-collapse: collapse; border: 3px solid #0000FF" bordercolorlight="#0000FF">';
$table .= '<thead><tr><th>Colname1</th><th>Colname2</th><th>Colname2</th><th>Colname2</th><th>Colname2</th><th>Colname2</th><th>Colname2</th><th>Colname2</th><th>Colname2</th></tr></thead>';
$trimmed = trim($myfile);
$filearray = explode("'n", $trimmed);
foreach($filearray as $row) {
    // here separate your row that is a string, into an array
    $cols = explode(" ", $row);
    $table .= '<tr>';
    foreach($cols as $value) {
        $table .= '<td align = "center">'.$value.'</td>';
    }
    $table .= '</tr>';
}
$table .= '</table>';
echo $table;  
相关文章:
  • 没有找到相关文章