[eluser]Bigil Michael[/eluser]
i want to list the result in a dropdown box like this
Quote:category1
subcategory1
subcategory2
subcategory3
....
category2
subcategory
subcategory
for this i write the model view and controller and print the result in normal view page.
it is working well.
model
Quote:function select_all_state()
{
$this->db->select('id,heading');
$this->db->where('parent','0');
$result_product = $this->db->get('classifieds_categories');
return $result_product->result_array();
}
function list_all_state($cid)
{
$this->db->where('parent',$cid);
$result_product = $this->db->get('classifieds_categories');
return $result_product->result_array();
}
controller
Quote:$build_array = array();
$fleets = $this->Home_model->select_all_state();
foreach($fleets as $row){
$build_array[] = array (
'fleets_array' => $row,
'listefleets_array' => $this->Home_model->list_all_state($row['id'])
);
}
$this->data['meow'] = $build_array;
view
Quote:<?php
foreach ($meow as $crow)
{ ?>
<?php echo $crow['fleets_array']['heading'];?>
<?php
foreach ($crow['listefleets_array'] as $lrow)
{
?>
<p><?php echo $lrow['heading'];?> </p>
<?php
}
?>
<?php
}
?>
this code is working well
when i try to print the result in select box like this
Quote: <select name="category">
<option value="">Select Category</option>
<?php
foreach($meow as $crow)
{
?>
<option value="<?php echo $crow['id']?>" ><?php echo $crow['fleets_array']['heading'];?></option>
<?php
foreach ($crow['listefleets_array'] as $lrow)
{
?>
<option value="<?php echo $lrow['id']?>" ><?php echo $lrow['heading'];?></option>
<?php
}
?>
<?php
}
?>
</select>
category name listing inside dropdown/selectbox
but it shows an error
Quote:undefined index id
can anyone help me?
thanks in advance...