/*
初学,很笨的方法 :-)
调用方法:
$conn=mssql_connect("xxh","sa","");
mssql_select_db("HelloPHP");
$query="select * from Users";
$result=mssql_query($query);
MyShowTable($result);
*/
function MyShowTable($dataset)
{
$i=0;
//表格开始
echo "<TABLE BORDER='1'>\n";
//显示标题
echo " <tr>\n";
$row=mssql_fetch_array($dataset);
//为了显示表头
$tmprow=$row;
//*************************************************************
//显示表头
//*************************************************************
if($tmprow)
{
$i=0;
while (next($tmprow))
{
echo " <td>".key($tmprow)."</td>\n";
next($tmprow);
$i++;
}
echo " <td>".key($tmprow)."</td>\n";
}
echo " </tr>\n";
//*************************************************************
while($row)
{
//print_r($row);
echo " <tr>\n";
for ($i=0;$i<count($row)/2;$i++)
{
echo " <td>".$row[$i]."</td>\n";
}
echo " </tr>\n";
$row=mssql_fetch_array($dataset);
}
//表格结束
echo "</TABLE>\n";
}