尋找堆棧溢出我發現alternating row color。 雖然這似乎在靜態表上工作,但我的結果是所有行都是粉紅色的。我不能讓它與引導上的PHP動態創建的工作表中:Bootstrap在動態創建的表格中交替排列顏色
$mdbFile = "\myAccessDatabase.mdb";
$pdo = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$mdbFile", "", "");
$query = $pdo->prepare("SELECT * FROM Table");
$query->execute();
echo "<table class='table table-striped table-bordered table-hover table-condensed table-responsive'>";
echo "<thead><tr>";
echo "<th>Last</th><th>First</th><th>XXX</th><th>YYY</th><th>ZZZ</th><th>WWW</th>";
echo "</tr></thead>";
for($i=0; $row = $query->fetch(); $i++){
echo '<tbody><tr>';
//echo "<th scope='row'>1</th>";
echo "<td>".$row['LAST']."</td>";
echo "<td>".$row['FIRST']."</td>";
echo "<td>".$row['XXX']."</td>";
echo "<td>".$row['YYY']."</td>";
echo "<td>".$row['ZZZ']."</td>";
echo "<td>".$row['WWW']."</td>";
}
echo "</tr></tbody></table>";
unset($pdo);
unset($query);
CSS:
.table-striped>tbody>tr:nth-child(odd)>td,
.table-striped>tbody>tr:nth-child(odd)>th {
background-color: pink;
}
我希望更多的人花費盡可能多的時間來解決問題,因爲他們編輯問題的內容。儘管我同意語法和格式很重要,但即使格式正確,仍未解決的問題仍未解決。 – BarclayVision