php 连接并查询sql server数据库的解决办法

内容摘要
这篇文章主要为大家详细介绍了php 连接并查询sql server数据库的简单示例,具有一定的参考价值,可以用来参考一下。

php连接sql server数据库并查询,对此感兴趣的朋友,看看idc笔
文章正文

这篇文章主要为大家详细介绍了php 连接并查询sql server数据库的简单示例,具有一定的参考价值,可以用来参考一下。

php连接sql server数据库并查询,对此感兴趣的朋友,看看idc笔记做的技术笔记。经测试代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<code class="php">
/**
 * 连接并查询sql server数据库
 *
 * @param
 * @arrange (www.idcnote.com)
 **/
  
// Connect to the database (host, username, password)
$con = mssql_connect('localhost','admin','foo')
    or die('Could not connect to the server!');
  
// Select a database:
mssql_select_db('Northwind')
    or die('Could not select a database.');
  
// Example query: (TOP 10 equal LIMIT 0,10 in MySQL)
$SQL = "SELECT TOP 10 * FROM ExampleTable ORDER BY ID ASC";
  
// Execute query:
$result = mssql_query($SQL)
    or die('A error occured: ' . mysql_error());
  
// Get result count:
$Count = mssql_num_rows($result);
print "Showing $count rows:<hr/>\n\n";
  
// Fetch rows:
while ($Row = mssql_fetch_assoc($result)) {
  
    print $Row['Fieldname'] . "\n";
  
}
  
mssql_close($con);
 
 
/***   来自php教程(www.idcnote.com)   ***/</code>

注:关于php 连接并查询sql server数据库的简单示例的内容就先介绍到这里,更多相关文章的可以留意

代码注释

作者:喵哥笔记

IDC笔记

学的不仅是技术,更是梦想!