Dan*_*sen 5 php sql-server wordpress
在Wordpress中,如何从外部Microsoft SQL数据库中提取数据以显示为只读表?
需要说明的是,这不是关于如何将Wordpress转换为MS SQL的问题,而是如何从主Wordpress DB外部的源中提取特定小部件的数据.我需要从中获取的数据恰好位于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
Run Code Online (Sandbox Code Playgroud)
并将该数据显示在Wordpress页面上的表格中:
<table>
<tr>
<th>Store Name</th>
<th>Address</th>
<th>Store Hours</th>
</tr>
<!-- Display rows of store locations here -->
</table>
Run Code Online (Sandbox Code Playgroud)
Wordpress 在 PHP 上运行,因此您需要使用 SQL Server 的 PHP 提供程序。请参阅使用 PHP 访问 SQL Server 数据库。
如果您在 Linux 上托管 Wordpress,则需要 FreeTDS,请参阅PHP mssql 要求。