【问题标题】:How do I retrieve external data from MS SQL from a Wordpress Blog?如何从 Wordpress 博客中检索 MS SQL 的外部数据?
【发布时间】:2010-02-24 17:52:29
【问题描述】:

在 Wordpress 中,我如何从外部 Microsoft SQL 数据库中提取数据以显示为只读表?

需要明确的是,这不是关于如何将 Wordpress 转换为 MS SQL 的问题,而是如何从主 Wordpress 数据库之外的源中提取特定小部件的数据。我需要从中提取的数据恰好位于 MS SQL 数据库中。

为了举例,假设我需要提取商店位置和营业时间:

/* Retrieve store locations from the external MS SQL database*/

SELECT id, name, address, city, state, zip, phone, openingTime, closingTime
FROM locations
ORDER BY name

并将该数据显示到 Wordpress 页面上的表格中:

<table>
<tr>
    <th>Store Name</th>
    <th>Address</th>
    <th>Store Hours</th>
</tr>

<!-- Display rows of store locations here -->

</table>

【问题讨论】:

    标签: php sql-server wordpress


    【解决方案1】:

    Wordpress 在 PHP 上运行,因此您需要为 SQL Server 使用 PHP 提供程序。见Accessing SQL Server Databases with PHP

    如果您在 Linux 上托管 Wordpress,则需要 FreeTDS,请参阅 PHP mssql Requirements

    【讨论】:

    • 好资源! Linux 信息有助于参考,但目前我们在 Windows 服务器上运行 Apache、PHP 和 Wordpress。
    • 该链接有很多示例如何连接、执行查询、检索结果和迭代结果以及格式化输出 html。您需要这方面的帮助吗,或者您可以从这里获得帮助吗?
    • 不,那个微软页面很有帮助!我认为这就是我所需要的,但在选择答案并关闭问题之前,我会根据我的问题查看页面。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-06
    • 2010-11-15
    • 1970-01-01
    相关资源
    最近更新 更多