【发布时间】:2018-06-13 21:17:37
【问题描述】:
我有一个从文本文件中读取并允许用户进行搜索的代码,然后系统将结果显示在一个包含文件名和行号的表中。
我需要的是删除空的列。
我将不胜感激。
表格的错误在哪里?
表格代码和样式:
//display the table
echo '<table class = "minimalistBlack" border=2>';
$filenameHtml = '<tr>';
$lineNumberHtml = '<tr>';
foreach ($result as $item){
$filename = isset($item['filename']) ? $item['filename'] : '';
$lines = isset($item['lines']) ? implode(',',$item['lines']) : '';
//$filenameHtml .= "<th>$filename</th>";
$new_filename = str_replace('.txt', '.pdf',$filename);
$filenameHtml .= "<th><a href ='".$new_filename."'target='_blank'>$filename</a></th>";
$lineNumberHtml .= "<td>$lines</td>";
}
$filenameHtml .= '</tr>';
$lineNumberHtml .= '</tr>';
echo $filenameHtml.$lineNumberHtml;
echo '</table>';
}
?>
<html>
<head>
</head>
<meta http-equiv="Content-Language" content="ar-sa">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
#form {
background: -webkit-linear-gradient(bottom, #CCCCCC, #EEEEEE 175px);
background: -moz-linear-gradient(bottom, #CCCCCC, #EEEEEE 175px);
background: linear-gradient(bottom, #CCCCCC, #EEEEEE 175px);
margin: auto;
width: 200px;
height: 200px;
position: absolute;
font-family: Tahoma, Geneva, sans-serif;
font-size: 14px;
font-style: italic;
line-height: 24px;
font-weight: bold;
color: #09C;
text-decoration: none;
border-radius: 10px;
padding: 10px;
border: 1px solid #999;
border: inset 1px solid #333;
-webkit-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
}
table.minimalistBlack {
border: 3px solid #80E0FF;
width: 100%;
text-align: left;
border-collapse: collapse;
}
table.minimalistBlack td, table.minimalistBlack th {
border: 1px solid #000000;
padding: 5px 4px;
}
table.minimalistBlack tbody td {
font-size: 12px;
}
table.minimalistBlack thead {
background: #CFCFCF;
background: -moz-linear-gradient(top, #dbdbdb 0%, #d3d3d3 66%, #CFCFCF 100%);
background: -webkit-linear-gradient(top, #dbdbdb 0%, #d3d3d3 66%, #CFCFCF 100%);
background: linear-gradient(to bottom, #dbdbdb 0%, #d3d3d3 66%, #CFCFCF 100%);
border-bottom: 3px solid #000000;
}
table.minimalistBlack thead th {
font-size: 15px;
font-weight: bold;
color: #000000;
text-align: left;
}
table.minimalistBlack tfoot {
font-size: 14px;
font-weight: bold;
color: #000000;
border-top: 3px solid #000000;
}
table.minimalistBlack tfoot td {
font-size: 14px;
}
【问题讨论】:
标签: php css foreach html-table