Welcome Guest, Not a member yet? Register   Sign In
select box problem
#1

[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>&lt;?php echo $lrow['heading'];?&gt; </p>
&lt;?php
}
?&gt;
&lt;?php
}
?&gt;
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>
&lt;?php
foreach($meow as $crow)
{
?&gt;
<option value="&lt;?php echo $crow['id']?&gt;" >&lt;?php echo $crow['fleets_array']['heading'];?&gt;</option>
&lt;?php
foreach ($crow['listefleets_array'] as $lrow)
{
?&gt;
<option value="&lt;?php echo $lrow['id']?&gt;" >&lt;?php echo $lrow['heading'];?&gt;</option>
&lt;?php
}
?&gt;

&lt;?php
}
?&gt;
</select>

category name listing inside dropdown/selectbox
but it shows an error
Quote:undefined index id
can anyone help me?
thanks in advance...
#2

[eluser]Bigil Michael[/eluser]
sorry for this post
solved my problem




Theme © iAndrew 2016 - Forum software by © MyBB