2014-09-02 66 views
0

我确定我昨晚发布了这个,但是我找不到它,并且我的帐户说我已经提出了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>"; 
?> 
+1

您正在混合使用'mysqli'和'mysql'功能。 – 2014-09-02 08:45:39

+0

也看起来像youre'echo $ option;'在所需的HTML'