you mean:
$query = " SELECT ProvinceID, Description FROM province ORDER BY Description ASC ";
$result = @mysql_query ($query, $connection) or die (mysql_error());
while ($row = @mysql_fetch_array($result))
{
$options .= "<option value='{$row["ProviceID"]}'>{$row["Description"]}</option>\n";
}
$selectBox = "<select name='Provinces'>\n" . $options . "</select>\n";
echo $selectBox;
You can also set the selected item by using:
$query = " SELECT ProvinceID, Description FROM province ORDER BY Description ASC ";
$result = @mysql_query ($query, $connection) or die (mysql_error());
$selectedID = "1";
while ($row = @mysql_fetch_array($result))
{
$options .= "<option value='{$row["ProvinceID"]}'";
if ($row["ProvinceID"] == $selectedID)
{
$options .= " selected";
}
$options .= ">{$row["Description"]}</option>\n";
}
$selectBox = "<select name='Provinces'>\n" . $options . "</select>\n";
echo $selectBox;
Garth Hapgood - Strickland wrote:
I am trying to pull all data out of a table called "province" which has 2 fields "ProvinceID" and "Description" respectively.
Now I want to populate a list with all the data in the "descriptions" field.
Many thanx