Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
备用mysql表格行背景色_Mysql - Fatal编程技术网

备用mysql表格行背景色

备用mysql表格行背景色,mysql,Mysql,我正在尝试向mysql表添加其他行颜色。我使用此代码来响应表结构 //creating our table echo "<tr>"; echo "<th>ID</h3></th>"; echo "<th>First Name</th>"; echo "<th>Last Name</th>"; echo "<th>

我正在尝试向mysql表添加其他行颜色。我使用此代码来响应表结构

//creating our table    
    echo "<tr>";
        echo "<th>ID</h3></th>";
        echo "<th>First Name</th>";
        echo "<th>Last Name</th>";
        echo "<th>email</th>";
        echo "<th>street</th>";
        echo "<th>Suburb</th>";
        echo "<th>State</th>";
        echo "<th>Action</th>";
    echo "</tr>";
但这两种方法都不起作用。我怎样才能做到这一点

th:nth-child(odd) { background-color: #ccc; }

您要使
的背景色为浅灰色,不

在che azeh的建议下,我将我的评论作为一个答案重新发布。我解决了这个问题,删除了所有的表td css,并将css添加到表tr中,再加上一些其他的css小调整

我的错误,我只是想看看是否可以更改替代的表标题列,作为对基本想法的测试。然而,当我试图将css应用于表行tr:nth child(odd){background color:#ccc;}时,它不起作用,我没有正确阅读您的回复。如果我使用th:nth child(奇数){background color:#ccc;},它会成功地使表头中的替换列替换颜色,但是当我使用t:nth child(奇数){background color:#ccc;}时,不会应用任何样式。我通过删除所有表td css并将css添加到表tr中,再加上一些其他较小的css调整来解决这个问题,我认为你应该把你的解决方案作为一个答案。
table tr:nth-child(odd) { background-color: #ccc; }>";
th:nth-child(odd) { background-color: #ccc; }