I have a cities table in my database that contain the list of city and each city has their own id(Unique).
Now I want to show the list of city in a select box in my view page so that user can select the city from them.
I am using the below code in my controller:
$sql = mysql_query("select * from cities ORDER BY city_name");
if(mysql_num_rows($sql)>0){
while($row=mysql_fetch_array($sql))
{
echo '<option value="'.$row['city_name'].'">'.$row['city_name'].'</option>';
}
}
else
{
echo '<option selected="selected">No data</option>';
}
What code should I use in view to show the list if city in the select box?