我想从查询结果中显示一个下拉框但是我收到以下错误;在下拉框所在的位置,只有$ row显示没有实际内容
我的代码:
<?php
$start=$_GET['arrival'];
$end=$_GET['departure'];
$type=$_GET['type'];
$query = odbc_exec (odbc_connect("book", "", ""), "SELECT Location_id
FROM PITCH
WHERE (((PITCH.location_id) Not In (SELECT Location_Id FROM BOOKING
WHERE StartDate OR EndDate
NOT BETWEEN
#$start# -1 And #$end# +1)) AND ((PITCH.Type_name)='$type'))");
$result = odbc_result_all($query);
echo '<select name="type" id="type">
While ($row = odbc_fetch_array ($result))
{
<option> $row </option>
}
</select>';
?>
答案 0 :(得分:0)
以下是您的代码的样子:
<?php
$start = isset($_GET['arrival']) ? trim($_GET['arrival']):null;
$end = isset($_GET['departure']) ? trim($_GET['departure']):null;
$type = isset($_GET['type']) ? trim($_GET['type']):null;
$query = odbc_exec (odbc_connect("book", "", ""), "
SELECT Location_id
FROM PITCH
WHERE (((PITCH.location_id) NOT IN (SELECT Location_Id FROM BOOKING
WHERE StartDate OR EndDate
NOT BETWEEN #$start# -1 AND #$end# +1)) AND ((PITCH.Type_name)='$type'))
");
$result = odbc_result_all($query);
echo '<select name="type" id="type">';
While ($row = odbc_fetch_array ($result)) {
echo "<option> $row </option>";
}
echo '</select>';
您将在$ _GET字段中看到我使用了isset()函数。您应该养成习惯,因为它会检查您提到的字段是否已设置 - 以防止出错。
此外,请在开发计算机上保留错误报告。您可以这样做:
error_reporting(E_ALL);
ini_set('display_errors',1);
答案 1 :(得分:0)
<body style="margin: 0px; font-family: Helvetica; font-size: 18px;">
<header style="background-color: lightsteelblue; padding: 2px;">Hello</header>
<main style="overflow: auto; background-color: lightgrey; padding: 2px;">
<article style="height: 400px;">
Goodbye
</article>
</main>
<footer style="background-color: lightsteelblue; padding: 2px;">I don't know why you say, "Goodbye"; I say, "Hello."</footer>
</body>