duanhan5388 2019-06-24 08:05
浏览 50

从外部php文件添加html文件中的行

I'm trying to find how to insert a row line to a table in html so , but i would like to do it using an external php file, but maybe another solution because the purpose is to get a table from a database one and write it down to an html table.

i've tried to look on the internet but i didn't find something that was fitting with what i was lookin for.

  • 写回答

1条回答 默认 最新

  • doufu7835 2019-06-24 08:20
    关注

    Do you mean some thing like "example 1" from here (https://www.php.net/manual/en/mysqli-result.fetch-assoc.php)?

    You only need to add the html tags to create the html table (table, td, ...).

    EDIT:

    This example includes the html tags and should do what you want:

    <html>
    ...
    <body>
    <?php
    
       $mysqli = new mysqli("localhost", "my_user", "my_password", "database");
    
       $query = "SELECT Name, CountryCode FROM City ORDER by ID DESC LIMIT 50,5";
    
       if ($result = $mysqli->query($query)) {
    
           echo "<table>";
           /* fetch associative array */
           while ($row = $result->fetch_assoc()) {
               echo "<tr><td>" . $row['Name'] . "</td><td>" . $row['CountryCode'] . "</td></tr>";
           }
           echo "</table>";
    
           /* free result set */
           $result->free();
       }
    ?>
    </body>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器