我刚刚从PHPmyadmin中找到了如何显示我的表,但我希望第五行有一个虚线轮廓。我知道如何在css"border-style:虚线;"中制作虚线边框。问题是我的代码是如何从数据库中调用数据并将其放入HTML表中的,我是否需要重新编码以使第五行变为虚线?
// Get all the data from the "epl" table
$result = mysql_query("SELECT * FROM epl")
or die(mysql_error());
echo "<table border='1'>";
echo "<tr> <th>Pos</th> <th>Team</th> <th>PLD</th> <th>W</th> <th>D</th>
<th>L</th> <th>F</th> <th>A</th> <th>GD</th> <th>PTS</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['Pos'];
echo "</td><td>";
echo $row['Team'];
echo "</td><td>";
echo $row['PLD'];
echo "</td><td>";
echo $row['W'];
echo "</td><td>";
echo $row['D'];
echo "</td><td>";
echo $row['L'];
echo "</td><td>";
echo $row['F'];
echo "</td><td>";
echo $row['A'];
echo "</td><td>";
echo $row['GD'];
echo "</td><td>";
echo $row['PTS'];
echo "</td></tr>";
}
我想做的一个例子是http://www.bbc.co.uk/sport/football/tables'
$count = 1;
while($row = mysql_fetch_array( $result )) {
if($count == 5) {
echo "<tr style='border-style:dashed'><td>";
}
else {
echo "<tr><td>";
}
//other table stuff
$count++;
}
不是很优雅,但应该可以。
也许
$count = 1;
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
if($count === 5){
echo "<tr class="dashed"><td>";
} else {
echo "<tr><td>";
}
//All others <td>
$count++;
}
然后创建一个CSS类
.dashed { border-bottom: 1px dashed white; }