passing an array to a view in CodeIgniterphp - How do I fix this illegal offset type errorHow should I choose an authentication library for CodeIgniter?PHP: Delete an element from an arrayFatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (CodeIgniter + XML-RPC)Get the first element of an arrayHow to Sort Multi-dimensional Array by Value?Remove empty array elementsPHP array delete by value (not key)Combining and returning arrays from Model to Controller - CodeIgniterMysql, the last decimal zero disappears in Float data type for product pricesajax dependent dropdown codeigniter
Where in the Bible does the greeting ("Dominus Vobiscum") used at Mass come from?
There is only s̶i̶x̶t̶y one place he can be
Irreducibility of a simple polynomial
Why Were Madagascar and New Zealand Discovered So Late?
Generic lambda vs generic function give different behaviour
Products and sum of cubes in Fibonacci
What to do with wrong results in talks?
At which point does a character regain all their Hit Dice?
Hide Select Output from T-SQL
How does a character multiclassing into warlock get a focus?
Do I need a multiple entry visa for a trip UK -> Sweden -> UK?
Can a monster with multiattack use this ability if they are missing a limb?
when is out of tune ok?
What would happen if the UK refused to take part in EU Parliamentary elections?
Is exact Kanji stroke length important?
Is a roofing delivery truck likely to crack my driveway slab?
Mapping a list into a phase plot
Everything Bob says is false. How does he get people to trust him?
The plural of 'stomach"
What is the intuitive meaning of having a linear relationship between the logs of two variables?
What would be the benefits of having both a state and local currencies?
Cynical novel that describes an America ruled by the media, arms manufacturers, and ethnic figureheads
Why "be dealt cards" rather than "be dealing cards"?
Finding all intervals that match predicate in vector
passing an array to a view in CodeIgniter
php - How do I fix this illegal offset type errorHow should I choose an authentication library for CodeIgniter?PHP: Delete an element from an arrayFatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (CodeIgniter + XML-RPC)Get the first element of an arrayHow to Sort Multi-dimensional Array by Value?Remove empty array elementsPHP array delete by value (not key)Combining and returning arrays from Model to Controller - CodeIgniterMysql, the last decimal zero disappears in Float data type for product pricesajax dependent dropdown codeigniter
I have a model which looks like this
function find($where)
$arr = $this->db->get_where($this->table,$where)->result_array();
foreach ($arr as $value)
$prod_id = $value["id"];
$value['image']=$this->db->get_where("photos",['prod_id'=>$prod_id])->result_array();
return $value;
It gives me this array
Array(
[id] => 70
[name] => rrwerwer
[count] => 234
[price] => 234.00
[description] =>
[user_id] => 20
[image] => Array
(
[0] => Array
(
[id] => 88
[prod_id] => 70
[link] => 1_HP8l7LMMt7Sh5UoO1T-yLQ37.png
)))
In my Controller I have try to load a view and pass my array to it
$data = $this->productmodel->find(["user_id =" => $this->session->user["id"]]);
$this->load->view('myproduct', ["products" => $data]);
And in the view run a foreach on the array and print things
<?php foreach($products as $prod){ ?>
<div class="productDiv">
<div class="productName">
<span class="productNameSpan">
<?=$prod["name"]?>
</span>
</div>
<div class="productPrice">
<label class="productPriceLabel">Գին: <?=$prod["price"]." դրամ"?></label>
</div>
<div class="productCount">
<label class="productCountLabel">Քանակ: <?=$prod["count"]."X" ?></label>
</div>
<div class="productDescribtion">
<label class="productDescribtipnLabel">Նկարագիր: <?=$prod["description"] ?></label>
</div>
<div class="seeMoreDiv">
<button class="seeMoreButton btn btn-success">
ՏԵՍՆԵԼ ԱՎԵԼԻՆ
</button>
</div>
</div>
It gives me errors 'illegal offset name,price etc...'
How can I fix this problem?
I need to print the information of the product and show images of it
php codeigniter
add a comment |
I have a model which looks like this
function find($where)
$arr = $this->db->get_where($this->table,$where)->result_array();
foreach ($arr as $value)
$prod_id = $value["id"];
$value['image']=$this->db->get_where("photos",['prod_id'=>$prod_id])->result_array();
return $value;
It gives me this array
Array(
[id] => 70
[name] => rrwerwer
[count] => 234
[price] => 234.00
[description] =>
[user_id] => 20
[image] => Array
(
[0] => Array
(
[id] => 88
[prod_id] => 70
[link] => 1_HP8l7LMMt7Sh5UoO1T-yLQ37.png
)))
In my Controller I have try to load a view and pass my array to it
$data = $this->productmodel->find(["user_id =" => $this->session->user["id"]]);
$this->load->view('myproduct', ["products" => $data]);
And in the view run a foreach on the array and print things
<?php foreach($products as $prod){ ?>
<div class="productDiv">
<div class="productName">
<span class="productNameSpan">
<?=$prod["name"]?>
</span>
</div>
<div class="productPrice">
<label class="productPriceLabel">Գին: <?=$prod["price"]." դրամ"?></label>
</div>
<div class="productCount">
<label class="productCountLabel">Քանակ: <?=$prod["count"]."X" ?></label>
</div>
<div class="productDescribtion">
<label class="productDescribtipnLabel">Նկարագիր: <?=$prod["description"] ?></label>
</div>
<div class="seeMoreDiv">
<button class="seeMoreButton btn btn-success">
ՏԵՍՆԵԼ ԱՎԵԼԻՆ
</button>
</div>
</div>
It gives me errors 'illegal offset name,price etc...'
How can I fix this problem?
I need to print the information of the product and show images of it
php codeigniter
$prod id not an array that is why you are getting illegal offset error please echo $prod;die; or print_r($prod);die; to check it is an array or not
– Sayed Mohd Ali
Mar 8 at 9:42
Possible duplicate of php - How do I fix this illegal offset type error
– Sayed Mohd Ali
Mar 8 at 9:43
i think it's looking like object array , tryvar_dump
orprint_r
– Steve Good Job
Mar 8 at 10:22
add a comment |
I have a model which looks like this
function find($where)
$arr = $this->db->get_where($this->table,$where)->result_array();
foreach ($arr as $value)
$prod_id = $value["id"];
$value['image']=$this->db->get_where("photos",['prod_id'=>$prod_id])->result_array();
return $value;
It gives me this array
Array(
[id] => 70
[name] => rrwerwer
[count] => 234
[price] => 234.00
[description] =>
[user_id] => 20
[image] => Array
(
[0] => Array
(
[id] => 88
[prod_id] => 70
[link] => 1_HP8l7LMMt7Sh5UoO1T-yLQ37.png
)))
In my Controller I have try to load a view and pass my array to it
$data = $this->productmodel->find(["user_id =" => $this->session->user["id"]]);
$this->load->view('myproduct', ["products" => $data]);
And in the view run a foreach on the array and print things
<?php foreach($products as $prod){ ?>
<div class="productDiv">
<div class="productName">
<span class="productNameSpan">
<?=$prod["name"]?>
</span>
</div>
<div class="productPrice">
<label class="productPriceLabel">Գին: <?=$prod["price"]." դրամ"?></label>
</div>
<div class="productCount">
<label class="productCountLabel">Քանակ: <?=$prod["count"]."X" ?></label>
</div>
<div class="productDescribtion">
<label class="productDescribtipnLabel">Նկարագիր: <?=$prod["description"] ?></label>
</div>
<div class="seeMoreDiv">
<button class="seeMoreButton btn btn-success">
ՏԵՍՆԵԼ ԱՎԵԼԻՆ
</button>
</div>
</div>
It gives me errors 'illegal offset name,price etc...'
How can I fix this problem?
I need to print the information of the product and show images of it
php codeigniter
I have a model which looks like this
function find($where)
$arr = $this->db->get_where($this->table,$where)->result_array();
foreach ($arr as $value)
$prod_id = $value["id"];
$value['image']=$this->db->get_where("photos",['prod_id'=>$prod_id])->result_array();
return $value;
It gives me this array
Array(
[id] => 70
[name] => rrwerwer
[count] => 234
[price] => 234.00
[description] =>
[user_id] => 20
[image] => Array
(
[0] => Array
(
[id] => 88
[prod_id] => 70
[link] => 1_HP8l7LMMt7Sh5UoO1T-yLQ37.png
)))
In my Controller I have try to load a view and pass my array to it
$data = $this->productmodel->find(["user_id =" => $this->session->user["id"]]);
$this->load->view('myproduct', ["products" => $data]);
And in the view run a foreach on the array and print things
<?php foreach($products as $prod){ ?>
<div class="productDiv">
<div class="productName">
<span class="productNameSpan">
<?=$prod["name"]?>
</span>
</div>
<div class="productPrice">
<label class="productPriceLabel">Գին: <?=$prod["price"]." դրամ"?></label>
</div>
<div class="productCount">
<label class="productCountLabel">Քանակ: <?=$prod["count"]."X" ?></label>
</div>
<div class="productDescribtion">
<label class="productDescribtipnLabel">Նկարագիր: <?=$prod["description"] ?></label>
</div>
<div class="seeMoreDiv">
<button class="seeMoreButton btn btn-success">
ՏԵՍՆԵԼ ԱՎԵԼԻՆ
</button>
</div>
</div>
It gives me errors 'illegal offset name,price etc...'
How can I fix this problem?
I need to print the information of the product and show images of it
php codeigniter
php codeigniter
asked Mar 8 at 9:36
Grigory VolkovGrigory Volkov
61
61
$prod id not an array that is why you are getting illegal offset error please echo $prod;die; or print_r($prod);die; to check it is an array or not
– Sayed Mohd Ali
Mar 8 at 9:42
Possible duplicate of php - How do I fix this illegal offset type error
– Sayed Mohd Ali
Mar 8 at 9:43
i think it's looking like object array , tryvar_dump
orprint_r
– Steve Good Job
Mar 8 at 10:22
add a comment |
$prod id not an array that is why you are getting illegal offset error please echo $prod;die; or print_r($prod);die; to check it is an array or not
– Sayed Mohd Ali
Mar 8 at 9:42
Possible duplicate of php - How do I fix this illegal offset type error
– Sayed Mohd Ali
Mar 8 at 9:43
i think it's looking like object array , tryvar_dump
orprint_r
– Steve Good Job
Mar 8 at 10:22
$prod id not an array that is why you are getting illegal offset error please echo $prod;die; or print_r($prod);die; to check it is an array or not
– Sayed Mohd Ali
Mar 8 at 9:42
$prod id not an array that is why you are getting illegal offset error please echo $prod;die; or print_r($prod);die; to check it is an array or not
– Sayed Mohd Ali
Mar 8 at 9:42
Possible duplicate of php - How do I fix this illegal offset type error
– Sayed Mohd Ali
Mar 8 at 9:43
Possible duplicate of php - How do I fix this illegal offset type error
– Sayed Mohd Ali
Mar 8 at 9:43
i think it's looking like object array , try
var_dump
or print_r
– Steve Good Job
Mar 8 at 10:22
i think it's looking like object array , try
var_dump
or print_r
– Steve Good Job
Mar 8 at 10:22
add a comment |
1 Answer
1
active
oldest
votes
Don't use foreach()
and try like this
echo $products["price"];
Only use foreach()
on $products['image']
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%2f55060394%2fpassing-an-array-to-a-view-in-codeigniter%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Don't use foreach()
and try like this
echo $products["price"];
Only use foreach()
on $products['image']
add a comment |
Don't use foreach()
and try like this
echo $products["price"];
Only use foreach()
on $products['image']
add a comment |
Don't use foreach()
and try like this
echo $products["price"];
Only use foreach()
on $products['image']
Don't use foreach()
and try like this
echo $products["price"];
Only use foreach()
on $products['image']
answered Mar 8 at 9:40
Danish AliDanish Ali
1,70531021
1,70531021
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.
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%2f55060394%2fpassing-an-array-to-a-view-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
$prod id not an array that is why you are getting illegal offset error please echo $prod;die; or print_r($prod);die; to check it is an array or not
– Sayed Mohd Ali
Mar 8 at 9:42
Possible duplicate of php - How do I fix this illegal offset type error
– Sayed Mohd Ali
Mar 8 at 9:43
i think it's looking like object array , try
var_dump
orprint_r
– Steve Good Job
Mar 8 at 10:22