How to create HTML select lists in Joomla!

If you need create some HTML select list with items then you can use Joomla API.
Joomla! provide special class JHTML for creating form elements, such as selectlist, radiolist, booleanlist and etc…
Most popular. Get data from database and create selectlist.
Example ↓

$selected = JFactory::getInt('selectlist_name', 0); 

$db = JFactory::getDBO();
    $query = "SELECT `id` AS `value`, `title` AS `text` FROM `#__your_table` WHERE `cid`=1";
$items_from_db = $db->loadObjectList();

$selectlist_data[] = JHTML::_('select.option',  '0', "- Select item -", 'value', 'text' );
$selectlist_data = array_merge( $selectlist_data, $items_from_db);

$list = JHTML::_( 'select.genericlist',
                    'size="1" class="inputbox selectlist"', 
                    'value', 'text', 
                    $selected, 'selectlist_id', 
echo $list;

Result ↓