此处的代码在 Chrome 中有效,其中数据库列表显示在下拉框中,但是在 IE 中它只是列出而不在下拉框中:
if (!$result)
{
/*echo $query;*/
$message = 'ERROR: ' . sqlsrv_errors();
return $message;
}
else
{
$i = 0;
echo '<html><body><table><tr><td> Forte ID: </td></tr><select id="ForteID" name="ForteID"><table width="150"><tr>';
while ($i < sqlsrv_num_rows($result))
{
$meta = sqlsrv_fetch($result, $i);
echo '<td>' . $meta->name . '</td>';
$i = $i + 1;
}
echo '';
while ( $row = sqlsrv_fetch_array( $result, SQLSRV_FETCH_ASSOC ))
{
$count = count($row);
$y = 0;
echo '<tr><option>';
while ($y < $count)
{
$c_row = current($row);
echo '<td>' . $c_row . '</td>';
next($row);
$y = $y + 1;
}
echo '</option></tr>';
}
sqlsrv_free_stmt ($result);
echo '</table></select></body></html>';
}
sqlsrv_close( $connection);
?>
让我知道是否需要更好地描述。提前致谢!
编辑:
这就是我现在所拥有的:
<?php
$serverName = 'localhost\SQLEXPRESS';
$connectionInfo = array('Database'=>'database', 'UID'=>'username', 'PWD'=>'password','ReturnDatesAsStrings'=>true,);
$connection = sqlsrv_connect($serverName, $connectionInfo);
$query = ' SELECT Column1
FROM database.dbo.Reps
ORDER By Column1';
$result = sqlsrv_query($connection,$query);
// Move the data to a simple array to simplify presentation code.
$resultAsArray = array();
while ( $row = sqlsrv_fetch_array( $result, SQLSRV_FETCH_ASSOC )) {
$resultAsArray []= $row;
}
?>
<form method="get" action="getlog.php">
<select>
<?php foreach ($resultAsArray as $row): ?>
<option value="<?php= $row['Column1'] ?>"><?php= $row['Column1'] ?></option>
<?php endforeach; ?>
</select>
<input type="submit" name="getLog" value="Get Log">
</form>
</html>