how to get data from the 3 tables according to date wise in codeiginter?
public function St_statement() {
$startdate = $this->input->post('SDate');
$enddate = $this->input->post('EDate');
$date = str_replace('/', '-', $startdate);
$newDate = date("Y-m-d", strtotime($date));
$date2 = str_replace('/', '-', $enddate);
$newDate2 = date("Y-m-d", strtotime($date2));
$data['startdate'] = $startdate;
$data['enddate'] = $enddate;
if ($this->input->post('all')) {
$query1 = $this->db->query("SELECT `pgroup`,`Item`, SUM(`Stock`) AS `Stock`,SUM(`quantity`) AS `quantity`,SUM(`Qty`) AS `Qty`FROM `opstock` LEFT OUTER JOIN `salesitem` ON `salesitem`.`Prdtname` = `opstock`.`Item` LEFT OUTER JOIN `itemmaster` ON `itemmaster`.`itemname` = `opstock`.`Item` LEFT OUTER JOIN `pgroup` ON `pgroup`.`pgroupid` = `itemmaster`.`catcode` LEFT OUTER JOIN `purchaseitem` ON `purchaseitem`.`Prdtname` = `opstock`.`Item` WHERE billdte >= '$newDate' AND billdte <= '$newDate2' AND billdate >= '$newDate' AND billdate <= '$newDate2' GROUP BY `Item` ORDER BY `pgroup` ASC ")->result_array();
$data['query'] = $query1;
$this->load->view('Inventory/St_Stmt', $data);
}
if ($this->input->post('selected')) {
if ($name = $this->input->post('businessType')) {
$query1 = $this->db->query("SELECT `pgroup`,`Item`, SUM(`Stock`) AS `Stock`,SUM(`quantity`) AS `quantity`,SUM(`Qty`) AS `Qty`FROM `opstock` LEFT OUTER JOIN `salesitem` ON `salesitem`.`Prdtname` = `opstock`.`Item` LEFT OUTER JOIN `itemmaster` ON `itemmaster`.`itemname` = `opstock`.`Item` LEFT OUTER JOIN `pgroup` ON `pgroup`.`pgroupid` = `itemmaster`.`catcode` LEFT OUTER JOIN `purchaseitem` ON `purchaseitem`.`Prdtname` = `opstock`.`Item` WHERE `pgroup` = '$name' AND billdte >= '$newDate' AND billdte <= '$newDate2' AND billdate >= '$newDate' AND billdate <= '$newDate2' GROUP BY `Item` ORDER BY `pgroup` ASC")->result_array();
$data['query'] = $query1;
$this->load->view('Inventory/St_Stmt', $data);
}
}
}
this is a controller code.....
my problem is how to get data from the four tables using date wise in codeiginter.
when i using where condition it only fetch the data if all the tables presents, otherwise it does not display the item.
this picture used where condition.it shows only all three tables have same item.
this picture does not used where condition but it shows all the data if it is not present or not.
please help to solve this problem
php mysql codeigniter join
add a comment |
public function St_statement() {
$startdate = $this->input->post('SDate');
$enddate = $this->input->post('EDate');
$date = str_replace('/', '-', $startdate);
$newDate = date("Y-m-d", strtotime($date));
$date2 = str_replace('/', '-', $enddate);
$newDate2 = date("Y-m-d", strtotime($date2));
$data['startdate'] = $startdate;
$data['enddate'] = $enddate;
if ($this->input->post('all')) {
$query1 = $this->db->query("SELECT `pgroup`,`Item`, SUM(`Stock`) AS `Stock`,SUM(`quantity`) AS `quantity`,SUM(`Qty`) AS `Qty`FROM `opstock` LEFT OUTER JOIN `salesitem` ON `salesitem`.`Prdtname` = `opstock`.`Item` LEFT OUTER JOIN `itemmaster` ON `itemmaster`.`itemname` = `opstock`.`Item` LEFT OUTER JOIN `pgroup` ON `pgroup`.`pgroupid` = `itemmaster`.`catcode` LEFT OUTER JOIN `purchaseitem` ON `purchaseitem`.`Prdtname` = `opstock`.`Item` WHERE billdte >= '$newDate' AND billdte <= '$newDate2' AND billdate >= '$newDate' AND billdate <= '$newDate2' GROUP BY `Item` ORDER BY `pgroup` ASC ")->result_array();
$data['query'] = $query1;
$this->load->view('Inventory/St_Stmt', $data);
}
if ($this->input->post('selected')) {
if ($name = $this->input->post('businessType')) {
$query1 = $this->db->query("SELECT `pgroup`,`Item`, SUM(`Stock`) AS `Stock`,SUM(`quantity`) AS `quantity`,SUM(`Qty`) AS `Qty`FROM `opstock` LEFT OUTER JOIN `salesitem` ON `salesitem`.`Prdtname` = `opstock`.`Item` LEFT OUTER JOIN `itemmaster` ON `itemmaster`.`itemname` = `opstock`.`Item` LEFT OUTER JOIN `pgroup` ON `pgroup`.`pgroupid` = `itemmaster`.`catcode` LEFT OUTER JOIN `purchaseitem` ON `purchaseitem`.`Prdtname` = `opstock`.`Item` WHERE `pgroup` = '$name' AND billdte >= '$newDate' AND billdte <= '$newDate2' AND billdate >= '$newDate' AND billdate <= '$newDate2' GROUP BY `Item` ORDER BY `pgroup` ASC")->result_array();
$data['query'] = $query1;
$this->load->view('Inventory/St_Stmt', $data);
}
}
}
this is a controller code.....
my problem is how to get data from the four tables using date wise in codeiginter.
when i using where condition it only fetch the data if all the tables presents, otherwise it does not display the item.
this picture used where condition.it shows only all three tables have same item.
this picture does not used where condition but it shows all the data if it is not present or not.
please help to solve this problem
php mysql codeigniter join
add a comment |
public function St_statement() {
$startdate = $this->input->post('SDate');
$enddate = $this->input->post('EDate');
$date = str_replace('/', '-', $startdate);
$newDate = date("Y-m-d", strtotime($date));
$date2 = str_replace('/', '-', $enddate);
$newDate2 = date("Y-m-d", strtotime($date2));
$data['startdate'] = $startdate;
$data['enddate'] = $enddate;
if ($this->input->post('all')) {
$query1 = $this->db->query("SELECT `pgroup`,`Item`, SUM(`Stock`) AS `Stock`,SUM(`quantity`) AS `quantity`,SUM(`Qty`) AS `Qty`FROM `opstock` LEFT OUTER JOIN `salesitem` ON `salesitem`.`Prdtname` = `opstock`.`Item` LEFT OUTER JOIN `itemmaster` ON `itemmaster`.`itemname` = `opstock`.`Item` LEFT OUTER JOIN `pgroup` ON `pgroup`.`pgroupid` = `itemmaster`.`catcode` LEFT OUTER JOIN `purchaseitem` ON `purchaseitem`.`Prdtname` = `opstock`.`Item` WHERE billdte >= '$newDate' AND billdte <= '$newDate2' AND billdate >= '$newDate' AND billdate <= '$newDate2' GROUP BY `Item` ORDER BY `pgroup` ASC ")->result_array();
$data['query'] = $query1;
$this->load->view('Inventory/St_Stmt', $data);
}
if ($this->input->post('selected')) {
if ($name = $this->input->post('businessType')) {
$query1 = $this->db->query("SELECT `pgroup`,`Item`, SUM(`Stock`) AS `Stock`,SUM(`quantity`) AS `quantity`,SUM(`Qty`) AS `Qty`FROM `opstock` LEFT OUTER JOIN `salesitem` ON `salesitem`.`Prdtname` = `opstock`.`Item` LEFT OUTER JOIN `itemmaster` ON `itemmaster`.`itemname` = `opstock`.`Item` LEFT OUTER JOIN `pgroup` ON `pgroup`.`pgroupid` = `itemmaster`.`catcode` LEFT OUTER JOIN `purchaseitem` ON `purchaseitem`.`Prdtname` = `opstock`.`Item` WHERE `pgroup` = '$name' AND billdte >= '$newDate' AND billdte <= '$newDate2' AND billdate >= '$newDate' AND billdate <= '$newDate2' GROUP BY `Item` ORDER BY `pgroup` ASC")->result_array();
$data['query'] = $query1;
$this->load->view('Inventory/St_Stmt', $data);
}
}
}
this is a controller code.....
my problem is how to get data from the four tables using date wise in codeiginter.
when i using where condition it only fetch the data if all the tables presents, otherwise it does not display the item.
this picture used where condition.it shows only all three tables have same item.
this picture does not used where condition but it shows all the data if it is not present or not.
please help to solve this problem
php mysql codeigniter join
public function St_statement() {
$startdate = $this->input->post('SDate');
$enddate = $this->input->post('EDate');
$date = str_replace('/', '-', $startdate);
$newDate = date("Y-m-d", strtotime($date));
$date2 = str_replace('/', '-', $enddate);
$newDate2 = date("Y-m-d", strtotime($date2));
$data['startdate'] = $startdate;
$data['enddate'] = $enddate;
if ($this->input->post('all')) {
$query1 = $this->db->query("SELECT `pgroup`,`Item`, SUM(`Stock`) AS `Stock`,SUM(`quantity`) AS `quantity`,SUM(`Qty`) AS `Qty`FROM `opstock` LEFT OUTER JOIN `salesitem` ON `salesitem`.`Prdtname` = `opstock`.`Item` LEFT OUTER JOIN `itemmaster` ON `itemmaster`.`itemname` = `opstock`.`Item` LEFT OUTER JOIN `pgroup` ON `pgroup`.`pgroupid` = `itemmaster`.`catcode` LEFT OUTER JOIN `purchaseitem` ON `purchaseitem`.`Prdtname` = `opstock`.`Item` WHERE billdte >= '$newDate' AND billdte <= '$newDate2' AND billdate >= '$newDate' AND billdate <= '$newDate2' GROUP BY `Item` ORDER BY `pgroup` ASC ")->result_array();
$data['query'] = $query1;
$this->load->view('Inventory/St_Stmt', $data);
}
if ($this->input->post('selected')) {
if ($name = $this->input->post('businessType')) {
$query1 = $this->db->query("SELECT `pgroup`,`Item`, SUM(`Stock`) AS `Stock`,SUM(`quantity`) AS `quantity`,SUM(`Qty`) AS `Qty`FROM `opstock` LEFT OUTER JOIN `salesitem` ON `salesitem`.`Prdtname` = `opstock`.`Item` LEFT OUTER JOIN `itemmaster` ON `itemmaster`.`itemname` = `opstock`.`Item` LEFT OUTER JOIN `pgroup` ON `pgroup`.`pgroupid` = `itemmaster`.`catcode` LEFT OUTER JOIN `purchaseitem` ON `purchaseitem`.`Prdtname` = `opstock`.`Item` WHERE `pgroup` = '$name' AND billdte >= '$newDate' AND billdte <= '$newDate2' AND billdate >= '$newDate' AND billdate <= '$newDate2' GROUP BY `Item` ORDER BY `pgroup` ASC")->result_array();
$data['query'] = $query1;
$this->load->view('Inventory/St_Stmt', $data);
}
}
}
this is a controller code.....
my problem is how to get data from the four tables using date wise in codeiginter.
when i using where condition it only fetch the data if all the tables presents, otherwise it does not display the item.
this picture used where condition.it shows only all three tables have same item.
this picture does not used where condition but it shows all the data if it is not present or not.
please help to solve this problem
php mysql codeigniter join
php mysql codeigniter join
edited Nov 20 '18 at 9:43
Nesku
318111
318111
asked Nov 20 '18 at 9:19
Teddy
5810
5810
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
move that where condition statement to "ON" it will work.
Eg.
LEFT OUTER JOIN `salesitem` ON `salesitem`.`Prdtname` = `opstock`.`Item` AND billdte >= '$newDate' AND billdte <= '$newDate2' AND billdate >= '$newDate' AND billdate <= '$newDate2'
If its in where , which is common for the all above conditions. That's why you are not getting any result. So remove it from where condition and move that condition to "ON" statement.
thank you @AGK i got the correct ans
– Teddy
Nov 20 '18 at 10:10
add a comment |
i can't comment so no insults :3 i did not really understand your problem but you need to put the query inside the modal or else why using codeigniter, and you can make functions insie the modal for each table and make the query easier without joint etc..
add a comment |
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',
autoActivateHeartbeat: false,
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53389753%2fhow-to-get-data-from-the-3-tables-according-to-date-wise-in-codeiginter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
move that where condition statement to "ON" it will work.
Eg.
LEFT OUTER JOIN `salesitem` ON `salesitem`.`Prdtname` = `opstock`.`Item` AND billdte >= '$newDate' AND billdte <= '$newDate2' AND billdate >= '$newDate' AND billdate <= '$newDate2'
If its in where , which is common for the all above conditions. That's why you are not getting any result. So remove it from where condition and move that condition to "ON" statement.
thank you @AGK i got the correct ans
– Teddy
Nov 20 '18 at 10:10
add a comment |
move that where condition statement to "ON" it will work.
Eg.
LEFT OUTER JOIN `salesitem` ON `salesitem`.`Prdtname` = `opstock`.`Item` AND billdte >= '$newDate' AND billdte <= '$newDate2' AND billdate >= '$newDate' AND billdate <= '$newDate2'
If its in where , which is common for the all above conditions. That's why you are not getting any result. So remove it from where condition and move that condition to "ON" statement.
thank you @AGK i got the correct ans
– Teddy
Nov 20 '18 at 10:10
add a comment |
move that where condition statement to "ON" it will work.
Eg.
LEFT OUTER JOIN `salesitem` ON `salesitem`.`Prdtname` = `opstock`.`Item` AND billdte >= '$newDate' AND billdte <= '$newDate2' AND billdate >= '$newDate' AND billdate <= '$newDate2'
If its in where , which is common for the all above conditions. That's why you are not getting any result. So remove it from where condition and move that condition to "ON" statement.
move that where condition statement to "ON" it will work.
Eg.
LEFT OUTER JOIN `salesitem` ON `salesitem`.`Prdtname` = `opstock`.`Item` AND billdte >= '$newDate' AND billdte <= '$newDate2' AND billdate >= '$newDate' AND billdate <= '$newDate2'
If its in where , which is common for the all above conditions. That's why you are not getting any result. So remove it from where condition and move that condition to "ON" statement.
answered Nov 20 '18 at 9:45
AGK
5812
5812
thank you @AGK i got the correct ans
– Teddy
Nov 20 '18 at 10:10
add a comment |
thank you @AGK i got the correct ans
– Teddy
Nov 20 '18 at 10:10
thank you @AGK i got the correct ans
– Teddy
Nov 20 '18 at 10:10
thank you @AGK i got the correct ans
– Teddy
Nov 20 '18 at 10:10
add a comment |
i can't comment so no insults :3 i did not really understand your problem but you need to put the query inside the modal or else why using codeigniter, and you can make functions insie the modal for each table and make the query easier without joint etc..
add a comment |
i can't comment so no insults :3 i did not really understand your problem but you need to put the query inside the modal or else why using codeigniter, and you can make functions insie the modal for each table and make the query easier without joint etc..
add a comment |
i can't comment so no insults :3 i did not really understand your problem but you need to put the query inside the modal or else why using codeigniter, and you can make functions insie the modal for each table and make the query easier without joint etc..
i can't comment so no insults :3 i did not really understand your problem but you need to put the query inside the modal or else why using codeigniter, and you can make functions insie the modal for each table and make the query easier without joint etc..
answered Nov 20 '18 at 9:41
ChiKa LiO
448
448
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53389753%2fhow-to-get-data-from-the-3-tables-according-to-date-wise-in-codeiginter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown