Welcome Guest, Not a member yet? Register   Sign In
selecting data from 2 tables
#1

[eluser]Bigil Michael[/eluser]
can any one help me the problem is "resut repeating".

my tables
Quote:table name: constituency_details


id constituency_name constituency_id elect_year

1 vattiyoorkavu 4 2010
2 parassala 1 2011
3 neyyattinkara 2 2011
8 nemom 9 2008

tablename:candidate_details

id constituency_id candidate_name candidate_party elect_year

1 2 Selvaraj CPM 2011
2 4 babu incu 2010
4 1 George INC 2011
5 1 Nagappan CPM 2011
6 1 Suresh BJP 2011
7 2 Ravi INC 2011
8 2 sajith BJP 2011

my controller
Quote:function index($pgoffset='')
{
$config['per_page'] = 9;

$this->data['pagetitle'] ='Election Results';

$build_array = array();
$fleets = $this->Election_result_model->select_constituency($config['per_page'], $pgoffset);

foreach($fleets as $row){
$build_array[] = array (
'fleets_array' => $row,
'listefleets_array' => $this->Election_result_model->list_constituency($row['constituency_id'])
);
}
$this->data['meow'] = $build_array;

$this->load->view('election_result',$this->data);
}

model
Quote:function select_constituency($limit=NULL, $pgoffset=NULL)
{
$sql = "SELECT constituency_details.constituency_name, constituency_details.elect_year, constituency_details.constituency_id FROM constituency_details JOIN candidate_details ON (candidate_details.constituency_id = constituency_details.constituency_id AND candidate_details.elect_year = constituency_details.elect_year) ORDER BY constituency_details.constituency_name";

$query = $this->db->query($sql);
return $query->result_array();
}

function list_constituency($cid)
{
$this->db->where('constituency_id',$cid);
$this->db->order_by('candidate_name');
$result_product = $this->db->get('candidate_details');
return $result_product->result_array();
}
view
Quote: <div id="t1">

&lt;?php
foreach ($meow as $crow)
{ ?&gt;
<div id="t2">
<div style="padding-bottom:10px; font-size:14px;">&lt;?php echo $crow['fleets_array']['constituency_name'];?&gt; &nbsp;&nbsp;&nbsp;&lt;?php echo $crow['fleets_array']['elect_year'];?&gt; </div>

&lt;?php
foreach ($crow['listefleets_array'] as $lrow)
{
?&gt;
<p>&lt;?=$lrow['candidate_name'];?&gt;</p>
<p>&lt;?= $lrow['candidate_party'];?&gt;</p>
<p>&lt;?= $lrow['candidate_votes'];?&gt; </p>
<p>&lt;?= $lrow['percentage_votes'];?&gt;</p>
&lt;?php
}
?&gt;
</div>
&lt;?php
}
?&gt;

</div>

it is working but result is repeating
result like this
Quote:neyyattinkara 2011

Ravi

INC

879879

20

sajith

BJP

7878

5

Selvaraj

CPM

123456876

75
neyyattinkara 2011

Ravi

INC

879879

20

sajith

BJP

7878

5

Selvaraj

CPM

123456876

75
neyyattinkara 2011

Ravi

INC

879879

20

sajith

BJP

7878

5

Selvaraj

CPM

123456876

75

can anyone help me
i dont know how to remove this problem
urgent.......

thanks in advance.......


Messages In This Thread
selecting data from 2 tables - by El Forum - 04-16-2011, 12:43 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 01:00 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 01:09 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 01:24 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 01:30 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 01:49 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 02:21 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 03:24 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 03:46 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 03:48 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 04:03 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 04:07 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 04:15 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 04:23 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 04:41 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 04:51 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 04:52 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 05:09 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 05:56 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 06:12 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 06:25 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 06:33 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 06:38 AM
selecting data from 2 tables - by El Forum - 04-16-2011, 06:47 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 12:34 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 12:44 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 12:51 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 01:01 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 01:03 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 01:07 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 01:09 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 01:10 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 01:17 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 01:23 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 01:29 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 01:38 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 01:45 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 02:28 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 02:40 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 02:45 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 03:04 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 03:11 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 03:15 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 03:16 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 03:22 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 03:23 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 03:25 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 03:31 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 03:33 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 03:53 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 04:52 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 05:09 AM
selecting data from 2 tables - by El Forum - 04-18-2011, 10:44 PM
selecting data from 2 tables - by El Forum - 04-19-2011, 06:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB