<?php
$db = &JFactory::getDBO();
$query = "SELECT DISTINCT title FROM #__categories WHERE published = '1' ORDER BY level";
$db->setQuery($query);
$rows = $db->loadObjectList();
?>
<?php foreach ($rows as $row) {
$query = "SELECT id FROM #__categories WHERE title = " . $row->title . " AND published = '1' LIMIT 1 ";
$db->setQuery($query);
$rowid = $db->loadResult();
?>
<option value="<?php echo $rowid;?>" >
<?php echo $row->title;?>
</option>
<?php }?>
solved Fetch category and article list joomla