<TBODY>和<BODY>有何区别,<TBODY>是什么元素?

    <tbody>是用在<table>内的比如:

<table>  
    <tbody>  
          <tr>  
                <td></td>  
          </tr>  
    </tbody>  
</table> 

      使用TBODY的目的是可以使得这些包含在内的代码不用在整个表格都解析后一起显示,就是说如果有多个行,那么如果得到一个TBODY行,就可以先显示一行。  
      BODY是HTML的文本体,一个HTML文件,只有一个BODY,而在TABLE中可以有多个TBODY

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<?php // 连接数据库 $conn = new mysqli("localhost", "root", "123456", "wyya"); // 检查连接是否成功 if ($conn->connect_error) { die("连接失败: " . $conn->connect_error); } // 查询数据 $tables = array("one_list", "two_list", "three_list", "four_list", "five_list"); $data = array(); foreach ($tables as $table) { $sql = "SELECT * FROM " . $table; $result = mysqli_query($conn, $sql); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $row['语种'] = substr($table, 0, -5); // 获取语种名称 $data[] = $row; } } } // 渲染 HTML 模板 ?> <!DOCTYPE html> <html> <head> <title>网易云音乐歌单</title> <style> table { border-collapse: collapse; width: 100%; } th, td { text-align: left; padding: 8px; } tr:nth-child(even) { background-color: #f2f2f2; } th { background-color: #4CAF50; color: white; } .language-button { background-color: #f2f2f2; padding: 8px 16px; border: none; cursor: pointer; display: inline-block; margin-right: 10px; } .chinese { color: #e60000; } .english { color: #0066cc; } .japanese { color: #ff9900; } .korean { color: #3385ff; } .cantonese { color: #009933; } </style> </head> <body> <div> <h2>网易云音乐歌单</h2> <div> <form method="get" action=""> <input type="hidden" name="table" value="<?php echo $tables[0]; ?>"> <button type="submit" class="language-button chinese">华语</button> </form> <form method="get" action=""> <input type="hidden" name="table" value="<?php echo $tables[1]; ?>"> <button type="submit" class="language-button english">英语</button> </form> <form method="get" action=""> <input type="hidden" name="table" value="<?php echo $tables[2]; ?>"> <button type="submit" class="language-button japanese">日语</button> </form> <form method="get" action=""> <input type="hidden" name="table" value="<?php echo $tables[3]; ?>"> <button type="submit" class="language-button korean">韩语</button> </form> <form method="get" action=""> <input type="hidden" name="table" value="<?php echo $tables[4]; ?>"> <button type="submit" class="language-button cantonese">粤语</button> </form> </div> </div> <?php if (!empty($data)) { ?> <table> <tbody> <tr> <th>歌单名</th> <th>歌单地址</th> <th>歌曲量</th> <th>播放量</th> <th>收藏量</th> <th>评论量</th> <th>分享量</th> <th>创建者</th> <th>创建时间</th> </tr> <?php foreach ($data as $row) { ?> <tr> <td><?php echo $row['歌单名']; ?></td> <td><a href="<?php echo $row['歌单地址']; ?>" target="_blank"><?php echo $row['歌单地址']; ?></a></td> <td><?php echo $row['歌曲量']; ?></td> <td><?php echo $row['播放量']; ?></td> <td><?php echo $row['收藏量']; ?></td> <td><?php echo $row['评论量']; ?></td> <td><?php echo $row['分享量']; ?></td> <td><?php echo $row['创建者']; ?></td> <td><?php echo $row['创建时间']; ?></td> </tr> <?php } ?> </tbody> </table> <?php } else { ?> <p>暂无数据</p> <?php } ?> </body> </html> <?php // 关闭连接 $conn->close()0>修改代码,通过点击按钮展示出对应的单个歌单
06-06

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值