How to print associative array in codeigniter
my controller is : **
public function getdatewiseOrder()
{
$cid = $this->input->post('cid');
$startdate = strtotime($this->input->post('start_date'));
$enddate = strtotime($this->input->post('end_date'));
$order = $this->model_reports->getdatewiseOrder($cid, $startdate, $enddate);
$x = 0;
foreach ($order as $key => $value) {
$item[$x] = $this->model_reports->getorderItem($value['id']);
$x = $x + 1;
}
$this->data['order'] = $order;
$this->data['item'] = $item;
$this->render_template('reports/leser_report', $this->data);
}
for check : after print_r of item variable i get data in this format:
Array (
[0] => Array (
[0] => Array (
[id] => 188
[order_id] => 93
[product_name] => 2
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 1
[qtypcs] => 2
[unit] =>
[rate] => 234
[amount] => 234.00
[tax_id] =>
[timestamp] => 2018-10-30 12:51:10
)
)
[1] => Array (
[0] => Array (
[id] => 191
[order_id] => 96
[product_name] => Small
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 5
[qtypcs] => 5
[unit] =>
[rate] => 100
[amount] => 500.00
[tax_id] =>
[timestamp] => 2018-11-15 09:49:41
)
[1] => Array (
[id] => 192
[order_id] => 96
[product_name] => Medium
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 5
[qtypcs] => 5
[unit] =>
[rate] => 90
[amount] => 450.00
[tax_id] =>
[timestamp] => 2018-11-15 09:49:43
)
)
[2] => Array (
[0] => Array (
[id] => 206
[order_id] => 105
[product_name] => Small
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 2
[qtypcs] => 50
[unit] =>
[rate] => 100
[amount] => 200.00
[tax_id] =>
[timestamp] => 2018-11-15 13:38:47
)
)
[3] => Array (
[0] => Array (
[id] => 207
[order_id] => 106
[product_name] => Medium
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 50
[qtypcs] => 100
[unit] =>
[rate] => 15
[amount] => 750.00
[tax_id] =>
[timestamp] => 2018-11-15 13:40:12
)
)
)
I have two tables order and order_item and i am fetch data from both
for fetching data from order table i use
- $order = $this->model_reports->getdatewiseOrder($cid, $startdate,
$enddate);
for fetching data from order_item i am using
$item[$x] = $this->model_reports->getorderItem($value['id']);
inside foreach loop
I want output in this format
enter image description here
arrays codeigniter
|
show 2 more comments
my controller is : **
public function getdatewiseOrder()
{
$cid = $this->input->post('cid');
$startdate = strtotime($this->input->post('start_date'));
$enddate = strtotime($this->input->post('end_date'));
$order = $this->model_reports->getdatewiseOrder($cid, $startdate, $enddate);
$x = 0;
foreach ($order as $key => $value) {
$item[$x] = $this->model_reports->getorderItem($value['id']);
$x = $x + 1;
}
$this->data['order'] = $order;
$this->data['item'] = $item;
$this->render_template('reports/leser_report', $this->data);
}
for check : after print_r of item variable i get data in this format:
Array (
[0] => Array (
[0] => Array (
[id] => 188
[order_id] => 93
[product_name] => 2
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 1
[qtypcs] => 2
[unit] =>
[rate] => 234
[amount] => 234.00
[tax_id] =>
[timestamp] => 2018-10-30 12:51:10
)
)
[1] => Array (
[0] => Array (
[id] => 191
[order_id] => 96
[product_name] => Small
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 5
[qtypcs] => 5
[unit] =>
[rate] => 100
[amount] => 500.00
[tax_id] =>
[timestamp] => 2018-11-15 09:49:41
)
[1] => Array (
[id] => 192
[order_id] => 96
[product_name] => Medium
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 5
[qtypcs] => 5
[unit] =>
[rate] => 90
[amount] => 450.00
[tax_id] =>
[timestamp] => 2018-11-15 09:49:43
)
)
[2] => Array (
[0] => Array (
[id] => 206
[order_id] => 105
[product_name] => Small
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 2
[qtypcs] => 50
[unit] =>
[rate] => 100
[amount] => 200.00
[tax_id] =>
[timestamp] => 2018-11-15 13:38:47
)
)
[3] => Array (
[0] => Array (
[id] => 207
[order_id] => 106
[product_name] => Medium
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 50
[qtypcs] => 100
[unit] =>
[rate] => 15
[amount] => 750.00
[tax_id] =>
[timestamp] => 2018-11-15 13:40:12
)
)
)
I have two tables order and order_item and i am fetch data from both
for fetching data from order table i use
- $order = $this->model_reports->getdatewiseOrder($cid, $startdate,
$enddate);
for fetching data from order_item i am using
$item[$x] = $this->model_reports->getorderItem($value['id']);
inside foreach loop
I want output in this format
enter image description here
arrays codeigniter
1
So you have an array of associative arrays. What's the question?
– Jamie_D
Nov 20 '18 at 9:38
Maybe more explanation rather than a bunch of codes. I even tried to edit your post but it's not possible.
– Colin Cline
Nov 20 '18 at 9:39
Please add echo<pre>;
beforeprint_r()
function used. If you just want to show the item variable
– Madhuri Patel
Nov 20 '18 at 9:40
Also, it depends on that why you want to print the array?
– Danish Ali
Nov 20 '18 at 10:16
I want show order details and order item details in view page and i have two table orders and order_item
– sumit saim
Nov 20 '18 at 12:32
|
show 2 more comments
my controller is : **
public function getdatewiseOrder()
{
$cid = $this->input->post('cid');
$startdate = strtotime($this->input->post('start_date'));
$enddate = strtotime($this->input->post('end_date'));
$order = $this->model_reports->getdatewiseOrder($cid, $startdate, $enddate);
$x = 0;
foreach ($order as $key => $value) {
$item[$x] = $this->model_reports->getorderItem($value['id']);
$x = $x + 1;
}
$this->data['order'] = $order;
$this->data['item'] = $item;
$this->render_template('reports/leser_report', $this->data);
}
for check : after print_r of item variable i get data in this format:
Array (
[0] => Array (
[0] => Array (
[id] => 188
[order_id] => 93
[product_name] => 2
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 1
[qtypcs] => 2
[unit] =>
[rate] => 234
[amount] => 234.00
[tax_id] =>
[timestamp] => 2018-10-30 12:51:10
)
)
[1] => Array (
[0] => Array (
[id] => 191
[order_id] => 96
[product_name] => Small
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 5
[qtypcs] => 5
[unit] =>
[rate] => 100
[amount] => 500.00
[tax_id] =>
[timestamp] => 2018-11-15 09:49:41
)
[1] => Array (
[id] => 192
[order_id] => 96
[product_name] => Medium
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 5
[qtypcs] => 5
[unit] =>
[rate] => 90
[amount] => 450.00
[tax_id] =>
[timestamp] => 2018-11-15 09:49:43
)
)
[2] => Array (
[0] => Array (
[id] => 206
[order_id] => 105
[product_name] => Small
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 2
[qtypcs] => 50
[unit] =>
[rate] => 100
[amount] => 200.00
[tax_id] =>
[timestamp] => 2018-11-15 13:38:47
)
)
[3] => Array (
[0] => Array (
[id] => 207
[order_id] => 106
[product_name] => Medium
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 50
[qtypcs] => 100
[unit] =>
[rate] => 15
[amount] => 750.00
[tax_id] =>
[timestamp] => 2018-11-15 13:40:12
)
)
)
I have two tables order and order_item and i am fetch data from both
for fetching data from order table i use
- $order = $this->model_reports->getdatewiseOrder($cid, $startdate,
$enddate);
for fetching data from order_item i am using
$item[$x] = $this->model_reports->getorderItem($value['id']);
inside foreach loop
I want output in this format
enter image description here
arrays codeigniter
my controller is : **
public function getdatewiseOrder()
{
$cid = $this->input->post('cid');
$startdate = strtotime($this->input->post('start_date'));
$enddate = strtotime($this->input->post('end_date'));
$order = $this->model_reports->getdatewiseOrder($cid, $startdate, $enddate);
$x = 0;
foreach ($order as $key => $value) {
$item[$x] = $this->model_reports->getorderItem($value['id']);
$x = $x + 1;
}
$this->data['order'] = $order;
$this->data['item'] = $item;
$this->render_template('reports/leser_report', $this->data);
}
for check : after print_r of item variable i get data in this format:
Array (
[0] => Array (
[0] => Array (
[id] => 188
[order_id] => 93
[product_name] => 2
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 1
[qtypcs] => 2
[unit] =>
[rate] => 234
[amount] => 234.00
[tax_id] =>
[timestamp] => 2018-10-30 12:51:10
)
)
[1] => Array (
[0] => Array (
[id] => 191
[order_id] => 96
[product_name] => Small
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 5
[qtypcs] => 5
[unit] =>
[rate] => 100
[amount] => 500.00
[tax_id] =>
[timestamp] => 2018-11-15 09:49:41
)
[1] => Array (
[id] => 192
[order_id] => 96
[product_name] => Medium
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 5
[qtypcs] => 5
[unit] =>
[rate] => 90
[amount] => 450.00
[tax_id] =>
[timestamp] => 2018-11-15 09:49:43
)
)
[2] => Array (
[0] => Array (
[id] => 206
[order_id] => 105
[product_name] => Small
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 2
[qtypcs] => 50
[unit] =>
[rate] => 100
[amount] => 200.00
[tax_id] =>
[timestamp] => 2018-11-15 13:38:47
)
)
[3] => Array (
[0] => Array (
[id] => 207
[order_id] => 106
[product_name] => Medium
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 50
[qtypcs] => 100
[unit] =>
[rate] => 15
[amount] => 750.00
[tax_id] =>
[timestamp] => 2018-11-15 13:40:12
)
)
)
I have two tables order and order_item and i am fetch data from both
for fetching data from order table i use
- $order = $this->model_reports->getdatewiseOrder($cid, $startdate,
$enddate);
for fetching data from order_item i am using
$item[$x] = $this->model_reports->getorderItem($value['id']);
inside foreach loop
I want output in this format
enter image description here
arrays codeigniter
arrays codeigniter
edited Nov 21 '18 at 6:55
sumit saim
asked Nov 20 '18 at 9:22
sumit saimsumit saim
43
43
1
So you have an array of associative arrays. What's the question?
– Jamie_D
Nov 20 '18 at 9:38
Maybe more explanation rather than a bunch of codes. I even tried to edit your post but it's not possible.
– Colin Cline
Nov 20 '18 at 9:39
Please add echo<pre>;
beforeprint_r()
function used. If you just want to show the item variable
– Madhuri Patel
Nov 20 '18 at 9:40
Also, it depends on that why you want to print the array?
– Danish Ali
Nov 20 '18 at 10:16
I want show order details and order item details in view page and i have two table orders and order_item
– sumit saim
Nov 20 '18 at 12:32
|
show 2 more comments
1
So you have an array of associative arrays. What's the question?
– Jamie_D
Nov 20 '18 at 9:38
Maybe more explanation rather than a bunch of codes. I even tried to edit your post but it's not possible.
– Colin Cline
Nov 20 '18 at 9:39
Please add echo<pre>;
beforeprint_r()
function used. If you just want to show the item variable
– Madhuri Patel
Nov 20 '18 at 9:40
Also, it depends on that why you want to print the array?
– Danish Ali
Nov 20 '18 at 10:16
I want show order details and order item details in view page and i have two table orders and order_item
– sumit saim
Nov 20 '18 at 12:32
1
1
So you have an array of associative arrays. What's the question?
– Jamie_D
Nov 20 '18 at 9:38
So you have an array of associative arrays. What's the question?
– Jamie_D
Nov 20 '18 at 9:38
Maybe more explanation rather than a bunch of codes. I even tried to edit your post but it's not possible.
– Colin Cline
Nov 20 '18 at 9:39
Maybe more explanation rather than a bunch of codes. I even tried to edit your post but it's not possible.
– Colin Cline
Nov 20 '18 at 9:39
Please add echo
<pre>;
before print_r()
function used. If you just want to show the item variable– Madhuri Patel
Nov 20 '18 at 9:40
Please add echo
<pre>;
before print_r()
function used. If you just want to show the item variable– Madhuri Patel
Nov 20 '18 at 9:40
Also, it depends on that why you want to print the array?
– Danish Ali
Nov 20 '18 at 10:16
Also, it depends on that why you want to print the array?
– Danish Ali
Nov 20 '18 at 10:16
I want show order details and order item details in view page and i have two table orders and order_item
– sumit saim
Nov 20 '18 at 12:32
I want show order details and order item details in view page and i have two table orders and order_item
– sumit saim
Nov 20 '18 at 12:32
|
show 2 more comments
0
active
oldest
votes
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%2f53389797%2fhow-to-print-associative-array-in-codeigniter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
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%2f53389797%2fhow-to-print-associative-array-in-codeigniter%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
1
So you have an array of associative arrays. What's the question?
– Jamie_D
Nov 20 '18 at 9:38
Maybe more explanation rather than a bunch of codes. I even tried to edit your post but it's not possible.
– Colin Cline
Nov 20 '18 at 9:39
Please add echo
<pre>;
beforeprint_r()
function used. If you just want to show the item variable– Madhuri Patel
Nov 20 '18 at 9:40
Also, it depends on that why you want to print the array?
– Danish Ali
Nov 20 '18 at 10:16
I want show order details and order item details in view page and i have two table orders and order_item
– sumit saim
Nov 20 '18 at 12:32