Page 1 of 1

Display One Row to Dropdown List?

Posted: Fri Mar 19, 2010 9:55 am
by nitediver

Code: Select all

 
----------------
id| type  | cost 
----------------
1 | reg   | 500 
2 | exp   | 600   
----------------
 

Code: Select all

 
<? 
include "conf.php"; 
 
echo "<p>Cost <select city=name id=name>";
 
$cost = "SELECT type,cost from destination";
$reqcost = mysql_query($city) or die ("Error!");
 
while($result=mysql_fetch_array($reqcost))
    {
    echo "<option value=$result[type]>$result[type]</option>";
    }
echo "</select>";
 
?>
 
How to display the output only in one option, because that code generating two,
Also, I want to display one row from database inside the option list,

Code: Select all

| reg   | 500

Re: Display One Row to Dropdown List?

Posted: Fri Mar 19, 2010 10:40 am
by wanger220
Not sure what you are trying to achieve here ... can you be more descriptive?

The while( ) loop will run through the entire database and repeat the code inside the { } ... and since you have two records in your database, it is generating two <option> lines.