Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.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
Php 特定表行周围的边框_Php_Html_Css_Html Table_Border - Fatal编程技术网

Php 特定表行周围的边框

Php 特定表行周围的边框,php,html,css,html-table,border,Php,Html,Css,Html Table,Border,我正在尝试仅在顶行周围创建边框!当前,边框将仅显示在表的外部。但我也希望在第一排周围有一个边界。有人能帮我吗?我希望“团队、正确的选秀和分数”这一行周围有一个边界 <body> <?=$leaguename?> <center><table cellspacing="0" style="width:400px; border:1px solid gray"> <? echo "<tr border=\"1

我正在尝试仅在顶行周围创建边框!当前,边框将仅显示在表的外部。但我也希望在第一排周围有一个边界。有人能帮我吗?我希望“团队、正确的选秀和分数”这一行周围有一个边界

<body>
    <?=$leaguename?>
    <center><table cellspacing="0" style="width:400px; border:1px solid gray">
    <?
    echo "<tr border=\"1\"><td> Team </td><td>Correct Picks</td><td>Points</td></tr>";
    while($row = mysql_fetch_array($memberslist)) {
        if ($row['User_ID'] == $id) {
            echo "<tr style=\"border:1px solid gray\" bgcolor=\"gray\"><td>" . $row['User_ID'] . "</td><td><b>" . $row['Correct_Picks'] . " </b> /" . $maxcorrectpicks . "</td><td>" . $row['Points'] . "</td></tr>";
        } else {
            echo "<tr><td>" . $row['User_ID'] . "</td><td><b>" . $row['Correct_Picks'] . " </b> /" . $maxcorrectpicks . "</td><td>" . $row['Points'] . "</td></tr>";
    }
    }
    ?>
    </table></center>

</body>

这是一种表象,因此将其混入PHP是一个坏主意。相反,请使用CSS:

tr:first-child td { border-top: 1px solid black; border-bottom: 1px solid black; }
tr:first-child td:first-child { border-left:1px solid black; }
tr:first-child td:last-child { border-right:1px solid black; }
IE7+8对*-子选择器的支持可能有点问题。如果它不在浏览器中工作,请考虑使用JavaScript填充。 您可能还希望将标题放在
元素中,以使
中包含数据的
成为
元素的第一行

e、 g


团队
1.

您确实需要这样做。您不能将
作为
的子级。将边框应用于第一个
style
属性,或者更好,将其放在CSS文件中。我尝试添加border=1,但不起作用。你可以发布你的建议吗?无效的非语义HTML,夹杂着大量PHP逻辑。如果你继续编写这样的代码,你很快就会陷入开发的地狱。检查一下像Symfony、Yii或CodeIgniter这样的MVC框架,如果可能的话,开始考虑使用基于CSS的布局。所有这些都不是无效的,因为它正在工作。是的,这不是一个理想的方式,但我现在不在乎。请帮我回答我的问题。
<table>
  <thead>
    <tr>
      <th>Team</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>1</td>
    </tr>
  </tbody>
</table>