Welcome Guest, Not a member yet? Register   Sign In
result is repeating
#1

[eluser]Bigil Michael[/eluser]
my table

Code:
id    city        state
1     tvm         kerala
2     test1       kerala
3     kkkk        Goa
4     chennai     tamilnadu

i want the result like this
kerala
tvm
test1

goa
kkkk

tamilnadu
chennai

can anyone help me

my controller
Quote:$ho = $this->Hotels_model->test1();
$this->data['ho'] = $ho;
foreach($ho as $row)
{
$this->data['hot']= $this->Hotels_model->test2($row->state);
}
$this->load->view('hotels/list_all_hotels', $this->data);

model

Quote:function test1()
{
$this->db->distinct();
$this->db->select('state');
$this->db->from('hotels');
$result_product = $this->db->get();
return $result_product->result();
}
function test2($state)
{
$this->db->distinct();
$this->db->select('city');
$this->db->from('hotels');
$this->db->where('state',$state);
$result_product = $this->db->get();
return $result_product->result();
}

view
Quote:<?php
foreach ($ho as $row)
{ ?>
<div style="margin-top:8px; font-size:14px; font-weight:bold;">&lt;?php echo $row->state;?&gt; </div>

&lt;?php
foreach ($hot as $lrow)
{
?&gt;
<div>&lt;?php echo $lrow->city;?&gt; </div>
&lt;?php
}
?&gt;
&lt;?php
}
?&gt;


now my result is
city is same for all states............

can anyone help me urgent
thanks in advance..
#2

[eluser]Bigil Michael[/eluser]
can anyone help me urgent




Theme © iAndrew 2016 - Forum software by © MyBB