douchen7555 2015-04-20 20:27
浏览 43

如何在PHP中创建一个表,每个单元格具有特定的宽度?

I've been searching and searching, but my little brain simply can't come to a solution with any of the guides in here.

I have this PHP code:

"echo("<center><p>");
while($row = mysqli_fetch_array($result))
  {
  echo $row['ID'] . " " . $row['Navn'] . " " . $row['Score'];
  echo "<br/>";
  }
echo("</p></center>");"

"Navn", "Score" and "ID" is put in a database, which this code is getting out looks like this:
24 hans 9895
23 simon 9895
22 Simon Hansen 9860

On the left (24, 23 etc) you see "ID", "Navn" in the middle and "Score" on the right - very pretty. What I now want to do, is to make a cell for each of those 3 and give them a certain width, so that it is less messy and more structured to look at. I hope someone understands what I mean, and that someone is willing to help :)

  • 写回答

1条回答 默认 最新

  • doufanglian7585 2015-04-20 20:34
    关注

    You need to use tables and then style them. Here's an example of how to use html tables (http://www.w3schools.com/tags/tag_table.asp):

    echo("<table>");
    while($row = mysqli_fetch_array($result))
    {
        echo "<tr><td width=50>" . $row['ID'] . "</td><td width=100>" . $row['Navn'] . "</td><td width=50" . $row['Score'] . "</td></tr>";
    }
    echo("</table>");
    

    I haven't tested the code but you get the idea.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用