duankuangxie9070 2013-12-05 13:26
浏览 72

如何在php和mysql中的特定行周围加一条虚线

I just found out how to display my table from PHPmyadmin but I would like the fifth row to have a dashed outline. I know how to make a dashed border in css "border-style:dashed;". The problem is how my code is calling my data from a database and putting it in a HTML table, do I need to re-code this to make the fifth row dashed?

// 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>"; 
} 

An example of what I'm trying to do is on 'http://www.bbc.co.uk/sport/football/tables'

  • 写回答

2条回答 默认 最新

  • donglei2022 2013-12-05 13:31
    关注
    $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++;
    }
    

    Not very elegant but it should work.

    评论

报告相同问题?

悬赏问题

  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里