dousong5492 2014-02-13 16:37 采纳率: 100%
浏览 49

使用一个全局数据库查询填充多个网页输出?

How can one make one global database query (with PHP) and then use all the output (multiple rows) on various places on a webpage?

I read that javascripts can be called for each specific field on a webpage that needs data, but this is inefficient with regards to performance.

The webpage would contact a sort of table-of-contents with version numbers next to each of them. Those version numbers are stored inside the database and calling the database 20 times for the 20 different fields would be inefficient.

Any suggestions on how to run say a PHP query globally when the page loads and then later in the page use the different output at different locations on the page?

QUESTION UPDATE WITH EXAMPLE OF DESIRED OUTPUT:

The webpage should show the following output:

Document Name            Document Version

DEPT A DOCS:
Doc ABC                    1.2
- Description of doc
Doc another doc            2.3
- Description of doc

DEPT B DOCS:
Yet another doc            0.9
- Description of doc
Doc XYZ                    3.0
- Description of doc

Each of the documents have its own version associated with it. Each document has its own table inside the database with its associated version and this can be queried from a Postgres function or View. I wish to query this function or view only once and then display the results in a sort of 'table-of-contents' style (or table sort of view) on the webpage.

Thank you

P.S. This is my first post here.

  • 写回答

2条回答 默认 最新

  • douyu9159 2014-02-13 16:39
    关注

    Make the query in a separate PHP page that is included in all the pages you want to use the information on.

    评论

报告相同问题?

悬赏问题

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