I got a code like this
$result1 = mysql_query("select distinct Countr开发者_JS百科y from mtable UNION SELECT DISTINCT MidEstimate FROM mtable");
$row = mysql_fetch_assoc( $result1 );
echo "<select>";
foreach($row as $vals)
{
echo "<option name='$vals'>$vals</option>";
}
echo "</select>";
The dropdownlist list is showing only one value ? I want the values from both columns in this list please help me to sort this
$result1 = mysql_query("select distinct Country from mtable UNION SELECT DISTINCT MidEstimate FROM mtable");
echo "<select>";
while($row = mysql_fetch_array($result1)){
echo "<option name=\"$row[0]\">$row[0]</option>";
}
echo "</select>";
$result1 = mysql_query("select distinct Country from mtable UNION SELECT DISTINCT MidEstimate FROM mtable");
echo "<select>";
while($row = mysql_fetch_assoc( $result1 ))
{
echo "<option name=\"$vals['Country']\">$vals['Country']</option>";
}
echo "</select>";
Because you are fecthing your result only once and mysql_fetch_assoc( $result1 ) gets only one row while you want all the rows
精彩评论