我確定我昨晚發佈了這個,但是我找不到它,並且我的帳戶說我已經提出了0個問題。無論如何...mysql數據庫作爲下拉列表的不同結果/ php
我在我的MySQL數據庫中包含英國縣的領域。我想在一個下拉框中列出這些內容,以便用戶選擇它們來選擇他們希望看到結果的英國地區。
我到目前爲止...但我的下拉框出現空的?
任何幫助非常感謝。
<?php
include 'connect.php';
//set variable
$option = '';
// Get the county names from database - no duplicates
$query = "SELECT DISTINCT tradingCounty FROM offers";
// execute the query, $result will hold all of the Counties in an array
$result = mysqli_query($con,$query);
while($row = mysql_fetch_array($result)) {
$option .="<option>" . $row['tradingCounty'] . "</option>";
echo $option;
}
echo "<form id='filter' name='filter' method='post' action='resultssimple.php'>
<p><label>County</label></p>
<select name='filter' id='filter'>" . $option . "</select>
</form>";
?>
您正在混合使用'mysqli'和'mysql'功能。 – 2014-09-02 08:45:39
也看起來像youre'echo $ option;'在所需的HTML'
我剛剛用'$ row = mysql_fetch_array'替換'$ row = mysqli_fetch_array'並且它現在似乎正在工作... – sturobinson81 2014-09-02 08:49:28