我的脚本在某处有问题,但不知道它到底在哪里不正确。这是代码:
<title>Log</title>
</head>
<h1> Log </h1>
<form method="get" action="getlog.php">
<table width="300" border="0">
<tr>
<td> Forte ID:</td>
<td><select id="ForteID" name="ForteID">
<option value="nc4682">nc4682</option>
<option value="bs1441">bs1441</option>
<option value="sp3212">sp3212</option>
</select></td>
</tr>
</table>
<input type="submit" name="getLog" value="Get Log">
</form>
</head>
<body>
</body>
</html>
<?php
/*print_r($_POST);*/
$serverName = 'SRB-Nick_Desktop\SQLEXPRESS';
$connectionInfo = array('Database'=>'cslogs', 'UID'=>'cslogslogin', 'PWD'=>'123456');
$connection = sqlsrv_connect($serverName, $connectionInfo);
$query = 'SELECT ForteID, Disposition, appNumber, Finance_Num, Num_Payments, ACH_CC, Notes from logs';
$result = sqlsrv_query($connection,$query);
if (!$result)
{
$message = 'ERROR: ' . sqlsrv_errors();
return $message;
}
else
{
$i = 0;
echo '<html><body><table><tr>';
while ($i < sqlsrv_num_rows($result))
{
$meta = sqlsrv_fetch($result, $i);
echo '<td>' . $meta->name . '</td>';
$i = $i + 1;
}
echo '</tr>';
while ( ($row = sqlsrv_fetch_array($result)))
{
$count = count($row);
$y = 0;
echo '<tr>';
while ($y < $count)
{
$c_row = current($row);
echo '<td>' . $c_row . '</td>';
next($row);
$y = $y + 1;
}
echo '</tr>';
}
sqlsrv_free_stmt ($result);
echo '</table></body></html>';
}
sqlsrv_close( $connection);
?>
这就是我得到的结果,无论在下拉框中选择什么并点击按钮获取日志。
nc4682 nc4682保存保存ASDF ASDF FDAS FDAS 1 1 CC CC ASDF ASDF bs1441 bs1441 LOC LOC AN00336862 AN00336862无无0 0 ACH ACH回退回退nc4682 nc4682保存保存AN00336862 AN00336862 easdf easdf 2 2 ACH ACH ASDF ASDF sp3212 sp3212塞尔塞尔NCXXXXXX1 NCXXXXXX1无无1 1 cc cc asdfasdfasdf asdfasdfasdf
每列都是重复的。应该有7列。