在 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>
最佳答案
Wordpress 在 PHP 上运行,因此您需要为 SQL Server 使用 PHP 提供程序。参见 Accessing SQL Server Databases with PHP .
如果您在 Linux 上托管 Wordpress,则需要 FreeTDS,请参阅 PHP mssql Requirements .
关于php - 如何从 Wordpress 博客的 MS SQL 检索外部数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2328224/