doumen6532 2015-06-27 11:15
浏览 47
已采纳

将php生成的数据发送到html元素

Lets say I have html page that has 3 elements. Content of those elements should be taken from data base and just put there. Now, I can take data from db, I made my html and css styling, only problem I have is I don't know how to update html page with php data taken from Db. I don't want to use echo since that will give me separate page, I thought about using php to open that html file and rewrite it dynamically but that seems bit extreme. Any suggestion ?

  • 写回答

1条回答 默认 最新

  • dou8mwz5079 2015-06-27 11:21
    关注

    Make the extension of your html page as .php Where you want to put data do something like this -

    <?php
        // write your select query
        $val = "data retrieved from php"
    ?>
    

    Where you want to place it in the DOM, do something like this -

    <div><?=$val?></div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!