这是我的表单页面:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Log</title>
</head>
<h1> Log </h1>
<form method="get" action="getlog2.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"><input type="button" value="Form" onClick="window.location.href='index.php';">
</form>
</head>
当我点击“获取日志”按钮时,这里的代码就是我的表格。
<?php
/*print_r($_POST);*/
$serverName = 'SRB-Nick_Desktop\SQLEXPRESS';
$connectionInfo = array('Database'=>'cslogs', 'UID'=>'cslogslogin', 'PWD'=>'123456','ReturnDatesAsStrings'=>true,);
$connection = sqlsrv_connect($serverName, $connectionInfo);
$query = 'SELECT ForteID, Disposition, appNumber, Finance_Num, Num_Payments, ACH_CC, Notes, Date from cslogs.dbo.logs WHERE ForteID = ' . $_GET['ForteID'];
$result = sqlsrv_query($connection,$query);
/*echo $_GET['ForteID'];*/
if (!$result)
{
/*echo $query;*/
$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, SQLSRV_FETCH_ASSOC ))
{
$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);
?>
然后转到输出的页面:
bs1441 LOC asldjfasdf srb-000001 1 cc collected payment 2012-11-07
我想用边框和标题格式化输出,这可能吗?提前谢谢!