我在PHP中回顯表。不必手動設置表格的樣式,我怎樣才能讓它爲我在style.css中列出的表格選擇相同的樣式?將style.css應用到echo表中
下面,我有迴音表的代碼和表中的style.css
echo "<table>";
echo "<thead>".
"<tr>".
'<th>ETF Ticker</th>'.
'<th>ETF Name</th>'.
'<th>1 Yr Direction %</th>'.
'<th>Holding Name</th>'.
'<th>Industry</th>'.
'<th>% of total</th>'.
"</tr>".
"</thead>";
// Loop to show results
while($row = mysqli_fetch_assoc($result))
{
echo "<tr>";
echo "<td>" . $row['ETF'] . "</td>";
echo "<td>" . $row['ETF NAME'] . "</td>";
echo "<td>" . $row['1 YR Direction %'] . "</td>";
echo "<td>" . $row['Holding Name'] . "</td>";
echo "<td>" . $row['Industry'] . "</td>";
echo "<td>" . $row['Percent Holdings'] . "</td>";
"</tr>";
}
echo "</table>";
CSS
table {
/* tables still need 'cellspacing="0"' in the markup */
border-collapse: collapse;
border-spacing: 0;
margin: 0 0 1.5em;
width: 100%;
display: block;
overflow-x: auto;
white-space: nowrap;
}
thead {
font-weight: bold;
border: 2px;
background-color: #992c29
color #f7f4f4;
text-align: center;
}
您已包括在文件中的CSS代碼你在哪裏打印表格嗎? – Varun