How to display data only once by using two different tables in codeigniter











up vote
1
down vote

favorite












I am preparing register that input from date and to date...That display the entries made by the user from date and to date...I want to display voucher no,billdate,qty,amount(present in purchase bill table) and product name(present in purchaseitem table) i want to print the product name on the same row according to the billno..(For this i am using group concat)...My problem is all the datas are displaying multiple times..I don't know where is the error in my code..What changes have to be done on my code to display the data only once..Below i have attached my code..Help me



Controller Code:



$this->db->where('date >=', $newDate);
$this->db->where('date <=', $newDate2);
$this->db->select('*');
$this->db->from('purchasebill');
$this->db->order_by("voucherno", "asc");
$this->db->join('parmaster','parmaster.Pcode = purchasebill.partyname','left outer');
$this->db->select('GROUP_CONCAT(Prdtname)as itemname',false);
$this->db->order_by('vno','asc');
$this->db->group_by('vno,billno');
$this->db->from('purchaseitem');


$query = $this->db->get('')->result_array();
$data ['query']= $query;


View code:



  <?php $rowcount = 1 ?>                            
<?php foreach ($query as $row): ?>

<tr>
<td><?=$rowcount;?></td>
<td><?=$row['voucherno'];?></td>
<td><?=$row['date'];?></td>
<td><?=$row['PName'];?></td>
<td><?=$row['sqty'];?></td>
<td><?=$row['billtot'];?></td>
<td><?=$row['itemname'];?></td>
<?php $rowcount +=1?>
<br>
<?php endforeach ?>
</tr>


I think the datas are printing multiple times because i have used two queries but passed on the same variable $data..Is there is any possibility to load multiple query result on the same view page..???










share|improve this question









New contributor




dhara is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Can you show how you're passing the $data array to the view and also your view code?
    – Davo
    2 days ago










  • Yeah sure...check on my edited post
    – dhara
    2 days ago










  • Ok, so your view looks fine. I'm almost completely sure the problem is in the query, have you tried your query on PhpMyAdmin or similar?. Use echo $this->db->last_query(); after your $query = $this->db->get('')->result_array(); line and then copy that line and try directly on the database, you may be getting duplicated rows there.
    – Davo
    2 days ago










  • Yeah sir..I tried groupconcat in phpmy admin there it works fine..Is there is any possibility to load two query results on the same view page because for both of the table i am using $query and pass it on data
    – dhara
    2 days ago










  • Now that I see, your sql query builder looks wrong, there's 2 selects and no clear way on how they should be executed. You can totally separate those queries, but first let's make sure you find the right SQL query. How does purchasebill links with purchaseitem.
    – Davo
    2 days ago















up vote
1
down vote

favorite












I am preparing register that input from date and to date...That display the entries made by the user from date and to date...I want to display voucher no,billdate,qty,amount(present in purchase bill table) and product name(present in purchaseitem table) i want to print the product name on the same row according to the billno..(For this i am using group concat)...My problem is all the datas are displaying multiple times..I don't know where is the error in my code..What changes have to be done on my code to display the data only once..Below i have attached my code..Help me



Controller Code:



$this->db->where('date >=', $newDate);
$this->db->where('date <=', $newDate2);
$this->db->select('*');
$this->db->from('purchasebill');
$this->db->order_by("voucherno", "asc");
$this->db->join('parmaster','parmaster.Pcode = purchasebill.partyname','left outer');
$this->db->select('GROUP_CONCAT(Prdtname)as itemname',false);
$this->db->order_by('vno','asc');
$this->db->group_by('vno,billno');
$this->db->from('purchaseitem');


$query = $this->db->get('')->result_array();
$data ['query']= $query;


View code:



  <?php $rowcount = 1 ?>                            
<?php foreach ($query as $row): ?>

<tr>
<td><?=$rowcount;?></td>
<td><?=$row['voucherno'];?></td>
<td><?=$row['date'];?></td>
<td><?=$row['PName'];?></td>
<td><?=$row['sqty'];?></td>
<td><?=$row['billtot'];?></td>
<td><?=$row['itemname'];?></td>
<?php $rowcount +=1?>
<br>
<?php endforeach ?>
</tr>


I think the datas are printing multiple times because i have used two queries but passed on the same variable $data..Is there is any possibility to load multiple query result on the same view page..???










share|improve this question









New contributor




dhara is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • Can you show how you're passing the $data array to the view and also your view code?
    – Davo
    2 days ago










  • Yeah sure...check on my edited post
    – dhara
    2 days ago










  • Ok, so your view looks fine. I'm almost completely sure the problem is in the query, have you tried your query on PhpMyAdmin or similar?. Use echo $this->db->last_query(); after your $query = $this->db->get('')->result_array(); line and then copy that line and try directly on the database, you may be getting duplicated rows there.
    – Davo
    2 days ago










  • Yeah sir..I tried groupconcat in phpmy admin there it works fine..Is there is any possibility to load two query results on the same view page because for both of the table i am using $query and pass it on data
    – dhara
    2 days ago










  • Now that I see, your sql query builder looks wrong, there's 2 selects and no clear way on how they should be executed. You can totally separate those queries, but first let's make sure you find the right SQL query. How does purchasebill links with purchaseitem.
    – Davo
    2 days ago













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am preparing register that input from date and to date...That display the entries made by the user from date and to date...I want to display voucher no,billdate,qty,amount(present in purchase bill table) and product name(present in purchaseitem table) i want to print the product name on the same row according to the billno..(For this i am using group concat)...My problem is all the datas are displaying multiple times..I don't know where is the error in my code..What changes have to be done on my code to display the data only once..Below i have attached my code..Help me



Controller Code:



$this->db->where('date >=', $newDate);
$this->db->where('date <=', $newDate2);
$this->db->select('*');
$this->db->from('purchasebill');
$this->db->order_by("voucherno", "asc");
$this->db->join('parmaster','parmaster.Pcode = purchasebill.partyname','left outer');
$this->db->select('GROUP_CONCAT(Prdtname)as itemname',false);
$this->db->order_by('vno','asc');
$this->db->group_by('vno,billno');
$this->db->from('purchaseitem');


$query = $this->db->get('')->result_array();
$data ['query']= $query;


View code:



  <?php $rowcount = 1 ?>                            
<?php foreach ($query as $row): ?>

<tr>
<td><?=$rowcount;?></td>
<td><?=$row['voucherno'];?></td>
<td><?=$row['date'];?></td>
<td><?=$row['PName'];?></td>
<td><?=$row['sqty'];?></td>
<td><?=$row['billtot'];?></td>
<td><?=$row['itemname'];?></td>
<?php $rowcount +=1?>
<br>
<?php endforeach ?>
</tr>


I think the datas are printing multiple times because i have used two queries but passed on the same variable $data..Is there is any possibility to load multiple query result on the same view page..???










share|improve this question









New contributor




dhara is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I am preparing register that input from date and to date...That display the entries made by the user from date and to date...I want to display voucher no,billdate,qty,amount(present in purchase bill table) and product name(present in purchaseitem table) i want to print the product name on the same row according to the billno..(For this i am using group concat)...My problem is all the datas are displaying multiple times..I don't know where is the error in my code..What changes have to be done on my code to display the data only once..Below i have attached my code..Help me



Controller Code:



$this->db->where('date >=', $newDate);
$this->db->where('date <=', $newDate2);
$this->db->select('*');
$this->db->from('purchasebill');
$this->db->order_by("voucherno", "asc");
$this->db->join('parmaster','parmaster.Pcode = purchasebill.partyname','left outer');
$this->db->select('GROUP_CONCAT(Prdtname)as itemname',false);
$this->db->order_by('vno','asc');
$this->db->group_by('vno,billno');
$this->db->from('purchaseitem');


$query = $this->db->get('')->result_array();
$data ['query']= $query;


View code:



  <?php $rowcount = 1 ?>                            
<?php foreach ($query as $row): ?>

<tr>
<td><?=$rowcount;?></td>
<td><?=$row['voucherno'];?></td>
<td><?=$row['date'];?></td>
<td><?=$row['PName'];?></td>
<td><?=$row['sqty'];?></td>
<td><?=$row['billtot'];?></td>
<td><?=$row['itemname'];?></td>
<?php $rowcount +=1?>
<br>
<?php endforeach ?>
</tr>


I think the datas are printing multiple times because i have used two queries but passed on the same variable $data..Is there is any possibility to load multiple query result on the same view page..???







php mysql codeigniter group-concat






share|improve this question









New contributor




dhara is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




dhara is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago





















New contributor




dhara is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









dhara

266




266




New contributor




dhara is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





dhara is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






dhara is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Can you show how you're passing the $data array to the view and also your view code?
    – Davo
    2 days ago










  • Yeah sure...check on my edited post
    – dhara
    2 days ago










  • Ok, so your view looks fine. I'm almost completely sure the problem is in the query, have you tried your query on PhpMyAdmin or similar?. Use echo $this->db->last_query(); after your $query = $this->db->get('')->result_array(); line and then copy that line and try directly on the database, you may be getting duplicated rows there.
    – Davo
    2 days ago










  • Yeah sir..I tried groupconcat in phpmy admin there it works fine..Is there is any possibility to load two query results on the same view page because for both of the table i am using $query and pass it on data
    – dhara
    2 days ago










  • Now that I see, your sql query builder looks wrong, there's 2 selects and no clear way on how they should be executed. You can totally separate those queries, but first let's make sure you find the right SQL query. How does purchasebill links with purchaseitem.
    – Davo
    2 days ago


















  • Can you show how you're passing the $data array to the view and also your view code?
    – Davo
    2 days ago










  • Yeah sure...check on my edited post
    – dhara
    2 days ago










  • Ok, so your view looks fine. I'm almost completely sure the problem is in the query, have you tried your query on PhpMyAdmin or similar?. Use echo $this->db->last_query(); after your $query = $this->db->get('')->result_array(); line and then copy that line and try directly on the database, you may be getting duplicated rows there.
    – Davo
    2 days ago










  • Yeah sir..I tried groupconcat in phpmy admin there it works fine..Is there is any possibility to load two query results on the same view page because for both of the table i am using $query and pass it on data
    – dhara
    2 days ago










  • Now that I see, your sql query builder looks wrong, there's 2 selects and no clear way on how they should be executed. You can totally separate those queries, but first let's make sure you find the right SQL query. How does purchasebill links with purchaseitem.
    – Davo
    2 days ago
















Can you show how you're passing the $data array to the view and also your view code?
– Davo
2 days ago




Can you show how you're passing the $data array to the view and also your view code?
– Davo
2 days ago












Yeah sure...check on my edited post
– dhara
2 days ago




Yeah sure...check on my edited post
– dhara
2 days ago












Ok, so your view looks fine. I'm almost completely sure the problem is in the query, have you tried your query on PhpMyAdmin or similar?. Use echo $this->db->last_query(); after your $query = $this->db->get('')->result_array(); line and then copy that line and try directly on the database, you may be getting duplicated rows there.
– Davo
2 days ago




Ok, so your view looks fine. I'm almost completely sure the problem is in the query, have you tried your query on PhpMyAdmin or similar?. Use echo $this->db->last_query(); after your $query = $this->db->get('')->result_array(); line and then copy that line and try directly on the database, you may be getting duplicated rows there.
– Davo
2 days ago












Yeah sir..I tried groupconcat in phpmy admin there it works fine..Is there is any possibility to load two query results on the same view page because for both of the table i am using $query and pass it on data
– dhara
2 days ago




Yeah sir..I tried groupconcat in phpmy admin there it works fine..Is there is any possibility to load two query results on the same view page because for both of the table i am using $query and pass it on data
– dhara
2 days ago












Now that I see, your sql query builder looks wrong, there's 2 selects and no clear way on how they should be executed. You can totally separate those queries, but first let's make sure you find the right SQL query. How does purchasebill links with purchaseitem.
– Davo
2 days ago




Now that I see, your sql query builder looks wrong, there's 2 selects and no clear way on how they should be executed. You can totally separate those queries, but first let's make sure you find the right SQL query. How does purchasebill links with purchaseitem.
– Davo
2 days ago












2 Answers
2






active

oldest

votes

















up vote
0
down vote













Yes, you can execute different queries and pass them individually to the view:



$this->db->select('*');
$this->db->from('purchasebill');
$this->db->where('date >=', $newDate);
$this->db->where('date <=', $newDate2);
$this->db->order_by("voucherno", "asc");
$this->db->join('parmaster','parmaster.Pcode = purchasebill.partyname','left outer');
$query1 = $this->db->get()->result_array();

$this->db->select('GROUP_CONCAT(Prdtname) AS itemname',false);
$this->db->order_by('vno','asc');
$this->db->group_by('vno,billno');
$this->db->from('purchaseitem');
$query2 = $this->db->get()->result_array();

$data['bills']= $query1;
$data['items']= $query2;

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


Then on your view, you can access the data in $bills and $items. My advice is that you play around and create just one query that brings all your information.






share|improve this answer





















  • getting error..undefined variable query1 and invalid argument supplied foreach
    – dhara
    23 hours ago










  • I am trying to achieve this through one query but i don't know how to fetch two datas from two different table..
    – dhara
    22 hours ago










  • If you're getting undefined query1 you need to debug what's being returned to $query1, where are you getting this error? in your view?
    – Davo
    13 hours ago


















up vote
0
down vote













$this->db->where('date >=', $newDate);
$this->db->where('date <=', $newDate2);
$this->db->select('purchasebill.*,GROUP_CONCAT(parmaster.Prdtname)as itemname');
$this->db->from('purchasebill');
$this->db->join('parmaster','parmaster.Pcode = purchasebill.partyname','left outer');
$this->db->order_by('vno','asc');
$this->db->group_by('vno,billno');


$query = $this->db->get()->result_array();
$data ['query']= $query;





share|improve this answer





















  • getting this error Not unique table/alias: 'purchasebill' SELECT purchaseitem.*, GROUP_CONCAT(parmaster.Prdtname)as itemname FROM (purchasebill) LEFT OUTER JOIN parmaster ON parmaster.Pcode = purchasebill.partyname LEFT OUTER JOIN purchasebill ON purchasebill.date = purchaseitem.billdate WHERE date >= '2018-11-09' AND date <= '2018-11-12' GROUP BY vno, billno ORDER BY vno asc
    – dhara
    15 hours ago











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






dhara is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239207%2fhow-to-display-data-only-once-by-using-two-different-tables-in-codeigniter%23new-answer', 'question_page');
}
);

Post as a guest
































2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













Yes, you can execute different queries and pass them individually to the view:



$this->db->select('*');
$this->db->from('purchasebill');
$this->db->where('date >=', $newDate);
$this->db->where('date <=', $newDate2);
$this->db->order_by("voucherno", "asc");
$this->db->join('parmaster','parmaster.Pcode = purchasebill.partyname','left outer');
$query1 = $this->db->get()->result_array();

$this->db->select('GROUP_CONCAT(Prdtname) AS itemname',false);
$this->db->order_by('vno','asc');
$this->db->group_by('vno,billno');
$this->db->from('purchaseitem');
$query2 = $this->db->get()->result_array();

$data['bills']= $query1;
$data['items']= $query2;

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


Then on your view, you can access the data in $bills and $items. My advice is that you play around and create just one query that brings all your information.






share|improve this answer





















  • getting error..undefined variable query1 and invalid argument supplied foreach
    – dhara
    23 hours ago










  • I am trying to achieve this through one query but i don't know how to fetch two datas from two different table..
    – dhara
    22 hours ago










  • If you're getting undefined query1 you need to debug what's being returned to $query1, where are you getting this error? in your view?
    – Davo
    13 hours ago















up vote
0
down vote













Yes, you can execute different queries and pass them individually to the view:



$this->db->select('*');
$this->db->from('purchasebill');
$this->db->where('date >=', $newDate);
$this->db->where('date <=', $newDate2);
$this->db->order_by("voucherno", "asc");
$this->db->join('parmaster','parmaster.Pcode = purchasebill.partyname','left outer');
$query1 = $this->db->get()->result_array();

$this->db->select('GROUP_CONCAT(Prdtname) AS itemname',false);
$this->db->order_by('vno','asc');
$this->db->group_by('vno,billno');
$this->db->from('purchaseitem');
$query2 = $this->db->get()->result_array();

$data['bills']= $query1;
$data['items']= $query2;

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


Then on your view, you can access the data in $bills and $items. My advice is that you play around and create just one query that brings all your information.






share|improve this answer





















  • getting error..undefined variable query1 and invalid argument supplied foreach
    – dhara
    23 hours ago










  • I am trying to achieve this through one query but i don't know how to fetch two datas from two different table..
    – dhara
    22 hours ago










  • If you're getting undefined query1 you need to debug what's being returned to $query1, where are you getting this error? in your view?
    – Davo
    13 hours ago













up vote
0
down vote










up vote
0
down vote









Yes, you can execute different queries and pass them individually to the view:



$this->db->select('*');
$this->db->from('purchasebill');
$this->db->where('date >=', $newDate);
$this->db->where('date <=', $newDate2);
$this->db->order_by("voucherno", "asc");
$this->db->join('parmaster','parmaster.Pcode = purchasebill.partyname','left outer');
$query1 = $this->db->get()->result_array();

$this->db->select('GROUP_CONCAT(Prdtname) AS itemname',false);
$this->db->order_by('vno','asc');
$this->db->group_by('vno,billno');
$this->db->from('purchaseitem');
$query2 = $this->db->get()->result_array();

$data['bills']= $query1;
$data['items']= $query2;

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


Then on your view, you can access the data in $bills and $items. My advice is that you play around and create just one query that brings all your information.






share|improve this answer












Yes, you can execute different queries and pass them individually to the view:



$this->db->select('*');
$this->db->from('purchasebill');
$this->db->where('date >=', $newDate);
$this->db->where('date <=', $newDate2);
$this->db->order_by("voucherno", "asc");
$this->db->join('parmaster','parmaster.Pcode = purchasebill.partyname','left outer');
$query1 = $this->db->get()->result_array();

$this->db->select('GROUP_CONCAT(Prdtname) AS itemname',false);
$this->db->order_by('vno','asc');
$this->db->group_by('vno,billno');
$this->db->from('purchaseitem');
$query2 = $this->db->get()->result_array();

$data['bills']= $query1;
$data['items']= $query2;

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


Then on your view, you can access the data in $bills and $items. My advice is that you play around and create just one query that brings all your information.







share|improve this answer












share|improve this answer



share|improve this answer










answered 2 days ago









Davo

41437




41437












  • getting error..undefined variable query1 and invalid argument supplied foreach
    – dhara
    23 hours ago










  • I am trying to achieve this through one query but i don't know how to fetch two datas from two different table..
    – dhara
    22 hours ago










  • If you're getting undefined query1 you need to debug what's being returned to $query1, where are you getting this error? in your view?
    – Davo
    13 hours ago


















  • getting error..undefined variable query1 and invalid argument supplied foreach
    – dhara
    23 hours ago










  • I am trying to achieve this through one query but i don't know how to fetch two datas from two different table..
    – dhara
    22 hours ago










  • If you're getting undefined query1 you need to debug what's being returned to $query1, where are you getting this error? in your view?
    – Davo
    13 hours ago
















getting error..undefined variable query1 and invalid argument supplied foreach
– dhara
23 hours ago




getting error..undefined variable query1 and invalid argument supplied foreach
– dhara
23 hours ago












I am trying to achieve this through one query but i don't know how to fetch two datas from two different table..
– dhara
22 hours ago




I am trying to achieve this through one query but i don't know how to fetch two datas from two different table..
– dhara
22 hours ago












If you're getting undefined query1 you need to debug what's being returned to $query1, where are you getting this error? in your view?
– Davo
13 hours ago




If you're getting undefined query1 you need to debug what's being returned to $query1, where are you getting this error? in your view?
– Davo
13 hours ago












up vote
0
down vote













$this->db->where('date >=', $newDate);
$this->db->where('date <=', $newDate2);
$this->db->select('purchasebill.*,GROUP_CONCAT(parmaster.Prdtname)as itemname');
$this->db->from('purchasebill');
$this->db->join('parmaster','parmaster.Pcode = purchasebill.partyname','left outer');
$this->db->order_by('vno','asc');
$this->db->group_by('vno,billno');


$query = $this->db->get()->result_array();
$data ['query']= $query;





share|improve this answer





















  • getting this error Not unique table/alias: 'purchasebill' SELECT purchaseitem.*, GROUP_CONCAT(parmaster.Prdtname)as itemname FROM (purchasebill) LEFT OUTER JOIN parmaster ON parmaster.Pcode = purchasebill.partyname LEFT OUTER JOIN purchasebill ON purchasebill.date = purchaseitem.billdate WHERE date >= '2018-11-09' AND date <= '2018-11-12' GROUP BY vno, billno ORDER BY vno asc
    – dhara
    15 hours ago















up vote
0
down vote













$this->db->where('date >=', $newDate);
$this->db->where('date <=', $newDate2);
$this->db->select('purchasebill.*,GROUP_CONCAT(parmaster.Prdtname)as itemname');
$this->db->from('purchasebill');
$this->db->join('parmaster','parmaster.Pcode = purchasebill.partyname','left outer');
$this->db->order_by('vno','asc');
$this->db->group_by('vno,billno');


$query = $this->db->get()->result_array();
$data ['query']= $query;





share|improve this answer





















  • getting this error Not unique table/alias: 'purchasebill' SELECT purchaseitem.*, GROUP_CONCAT(parmaster.Prdtname)as itemname FROM (purchasebill) LEFT OUTER JOIN parmaster ON parmaster.Pcode = purchasebill.partyname LEFT OUTER JOIN purchasebill ON purchasebill.date = purchaseitem.billdate WHERE date >= '2018-11-09' AND date <= '2018-11-12' GROUP BY vno, billno ORDER BY vno asc
    – dhara
    15 hours ago













up vote
0
down vote










up vote
0
down vote









$this->db->where('date >=', $newDate);
$this->db->where('date <=', $newDate2);
$this->db->select('purchasebill.*,GROUP_CONCAT(parmaster.Prdtname)as itemname');
$this->db->from('purchasebill');
$this->db->join('parmaster','parmaster.Pcode = purchasebill.partyname','left outer');
$this->db->order_by('vno','asc');
$this->db->group_by('vno,billno');


$query = $this->db->get()->result_array();
$data ['query']= $query;





share|improve this answer












$this->db->where('date >=', $newDate);
$this->db->where('date <=', $newDate2);
$this->db->select('purchasebill.*,GROUP_CONCAT(parmaster.Prdtname)as itemname');
$this->db->from('purchasebill');
$this->db->join('parmaster','parmaster.Pcode = purchasebill.partyname','left outer');
$this->db->order_by('vno','asc');
$this->db->group_by('vno,billno');


$query = $this->db->get()->result_array();
$data ['query']= $query;






share|improve this answer












share|improve this answer



share|improve this answer










answered 16 hours ago









Vijay Makwana

461320




461320












  • getting this error Not unique table/alias: 'purchasebill' SELECT purchaseitem.*, GROUP_CONCAT(parmaster.Prdtname)as itemname FROM (purchasebill) LEFT OUTER JOIN parmaster ON parmaster.Pcode = purchasebill.partyname LEFT OUTER JOIN purchasebill ON purchasebill.date = purchaseitem.billdate WHERE date >= '2018-11-09' AND date <= '2018-11-12' GROUP BY vno, billno ORDER BY vno asc
    – dhara
    15 hours ago


















  • getting this error Not unique table/alias: 'purchasebill' SELECT purchaseitem.*, GROUP_CONCAT(parmaster.Prdtname)as itemname FROM (purchasebill) LEFT OUTER JOIN parmaster ON parmaster.Pcode = purchasebill.partyname LEFT OUTER JOIN purchasebill ON purchasebill.date = purchaseitem.billdate WHERE date >= '2018-11-09' AND date <= '2018-11-12' GROUP BY vno, billno ORDER BY vno asc
    – dhara
    15 hours ago
















getting this error Not unique table/alias: 'purchasebill' SELECT purchaseitem.*, GROUP_CONCAT(parmaster.Prdtname)as itemname FROM (purchasebill) LEFT OUTER JOIN parmaster ON parmaster.Pcode = purchasebill.partyname LEFT OUTER JOIN purchasebill ON purchasebill.date = purchaseitem.billdate WHERE date >= '2018-11-09' AND date <= '2018-11-12' GROUP BY vno, billno ORDER BY vno asc
– dhara
15 hours ago




getting this error Not unique table/alias: 'purchasebill' SELECT purchaseitem.*, GROUP_CONCAT(parmaster.Prdtname)as itemname FROM (purchasebill) LEFT OUTER JOIN parmaster ON parmaster.Pcode = purchasebill.partyname LEFT OUTER JOIN purchasebill ON purchasebill.date = purchaseitem.billdate WHERE date >= '2018-11-09' AND date <= '2018-11-12' GROUP BY vno, billno ORDER BY vno asc
– dhara
15 hours ago










dhara is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















dhara is a new contributor. Be nice, and check out our Code of Conduct.













dhara is a new contributor. Be nice, and check out our Code of Conduct.












dhara is a new contributor. Be nice, and check out our Code of Conduct.















 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239207%2fhow-to-display-data-only-once-by-using-two-different-tables-in-codeigniter%23new-answer', 'question_page');
}
);

Post as a guest




















































































Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python