我想制作一个 jqgrid,并且想将 mssql 数据库中的 2 个表放在那里。 我制作了一个 .php 但不起作用,有人可以看一下为什么不起作用吗? 我是这件事的新手..
<?php
$myServer = "localhost";
$myUser = "root";
$myPass = "";
$myDB = "test";
//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
// Declare the SQL query for Database
$query = "Select [Column 1]";
$query = "From table_test1";
//Execute the SQL query and return records
$result = mssql_query($query);
//Display the results
while($row = mssql_fetch_array($result))
//Close the connection
mssql_close($dbhandle);
?>
和 jqgrid
<html>
<head>
<title id='Description'>Expedio Weekly Tickets</title>
<script src="js/jquery-1.11.0.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" media="screen"
href="Style/redmond/jquery-ui.min.css"/>
<script type="text/javascript">
$(document).ready(function (){
$("#grid").jqGrid({
data: mydata,
datatype: 'local',
width: 1320,
colNames: ["A", "B", "C"],
colModel:
[
{name: 'A', index: 'A', key: true, width:10},
{name: 'B', index: 'B', width:20},
{name: 'C', index: 'C', width:40}
],
pager: '#pager',
sortname: 'id',
viewrecords: true,
sortorder: "asc",
caption: "Test"
});
});
</script>
</head>
<body>
<table id="grid"></table>
<div id="pager"></div>
</body>
</html>
我收到此错误>>
fatal error :在第 8 行调用 C:\xampp\htdocs\Connect.php 中未定义的函数 mssql_connect()
最佳答案
该错误可能是由于缺少与 MSSQL 通信的 PHP 扩展而引起的。请阅读 php 手册中的如何安装 mssql 扩展:
<强> http://php.net/manual/en/mssql.setup.php - 特别是要求和安装
部分关于php - 如何在jqgrid上绑定(bind)mssql表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25990387/