show data to modals get error message in codeigniter
i want show data to modals but i got the error message, and i already do many ways still stuck pls help
Severity: Notice
Message: Trying to get property of non-object
here my code
this my Controller:
public function lihatdetail()
{
$this->load->model('Produk_m' , 'produk_m');
if(!empty($this->input->post('ids'))){
$data['detail'] = $this->produk_m->lihat_detail($this->input->post('ids'));
foreach ($data as $item) {
echo 'Nama Barang :'.$item[0]->nama_barang.'<br>';
}
}else{
echo 'ID Tidak diketahui';
}
}
this My Models:
public function lihat_detail($id){
$this->db->select('b.id_barang');
$this->db->select('b.nama_barang');
$this->db->select('b.deskripsi_barang');
$this->db->select('b.stok_barang');
$this->db->select('b.size_barang');
$this->db->select('b.berat_barang');
$this->db->select('b.foto_barang');
$this->db->select('k.nama_kategori');
$this->db->select('b.harga_barang');
$this->db->select('b.status_barang');
$this->db->from('nm_barang b');
$this->db->join('nm_kategori_barang k', 'k.id_kategori = b.id_kategori');
$this->db->where('b.id_barang', $id);
$query = $this->db->get()->row_array();
}
and My Ajax:
$(document).on("click", ".kirimdata", function () {
var id_barang=$(this).data('id');
$.ajax({
type: 'POST',
url:'<?php echo base_url().'Produk/lihatdetail'?>',
data:{ ids: id_barang },
success:function(response){
$(".hasil-data").html(response);
}
});
});
php codeigniter-3
add a comment |
i want show data to modals but i got the error message, and i already do many ways still stuck pls help
Severity: Notice
Message: Trying to get property of non-object
here my code
this my Controller:
public function lihatdetail()
{
$this->load->model('Produk_m' , 'produk_m');
if(!empty($this->input->post('ids'))){
$data['detail'] = $this->produk_m->lihat_detail($this->input->post('ids'));
foreach ($data as $item) {
echo 'Nama Barang :'.$item[0]->nama_barang.'<br>';
}
}else{
echo 'ID Tidak diketahui';
}
}
this My Models:
public function lihat_detail($id){
$this->db->select('b.id_barang');
$this->db->select('b.nama_barang');
$this->db->select('b.deskripsi_barang');
$this->db->select('b.stok_barang');
$this->db->select('b.size_barang');
$this->db->select('b.berat_barang');
$this->db->select('b.foto_barang');
$this->db->select('k.nama_kategori');
$this->db->select('b.harga_barang');
$this->db->select('b.status_barang');
$this->db->from('nm_barang b');
$this->db->join('nm_kategori_barang k', 'k.id_kategori = b.id_kategori');
$this->db->where('b.id_barang', $id);
$query = $this->db->get()->row_array();
}
and My Ajax:
$(document).on("click", ".kirimdata", function () {
var id_barang=$(this).data('id');
$.ajax({
type: 'POST',
url:'<?php echo base_url().'Produk/lihatdetail'?>',
data:{ ids: id_barang },
success:function(response){
$(".hasil-data").html(response);
}
});
});
php codeigniter-3
add a comment |
i want show data to modals but i got the error message, and i already do many ways still stuck pls help
Severity: Notice
Message: Trying to get property of non-object
here my code
this my Controller:
public function lihatdetail()
{
$this->load->model('Produk_m' , 'produk_m');
if(!empty($this->input->post('ids'))){
$data['detail'] = $this->produk_m->lihat_detail($this->input->post('ids'));
foreach ($data as $item) {
echo 'Nama Barang :'.$item[0]->nama_barang.'<br>';
}
}else{
echo 'ID Tidak diketahui';
}
}
this My Models:
public function lihat_detail($id){
$this->db->select('b.id_barang');
$this->db->select('b.nama_barang');
$this->db->select('b.deskripsi_barang');
$this->db->select('b.stok_barang');
$this->db->select('b.size_barang');
$this->db->select('b.berat_barang');
$this->db->select('b.foto_barang');
$this->db->select('k.nama_kategori');
$this->db->select('b.harga_barang');
$this->db->select('b.status_barang');
$this->db->from('nm_barang b');
$this->db->join('nm_kategori_barang k', 'k.id_kategori = b.id_kategori');
$this->db->where('b.id_barang', $id);
$query = $this->db->get()->row_array();
}
and My Ajax:
$(document).on("click", ".kirimdata", function () {
var id_barang=$(this).data('id');
$.ajax({
type: 'POST',
url:'<?php echo base_url().'Produk/lihatdetail'?>',
data:{ ids: id_barang },
success:function(response){
$(".hasil-data").html(response);
}
});
});
php codeigniter-3
i want show data to modals but i got the error message, and i already do many ways still stuck pls help
Severity: Notice
Message: Trying to get property of non-object
here my code
this my Controller:
public function lihatdetail()
{
$this->load->model('Produk_m' , 'produk_m');
if(!empty($this->input->post('ids'))){
$data['detail'] = $this->produk_m->lihat_detail($this->input->post('ids'));
foreach ($data as $item) {
echo 'Nama Barang :'.$item[0]->nama_barang.'<br>';
}
}else{
echo 'ID Tidak diketahui';
}
}
this My Models:
public function lihat_detail($id){
$this->db->select('b.id_barang');
$this->db->select('b.nama_barang');
$this->db->select('b.deskripsi_barang');
$this->db->select('b.stok_barang');
$this->db->select('b.size_barang');
$this->db->select('b.berat_barang');
$this->db->select('b.foto_barang');
$this->db->select('k.nama_kategori');
$this->db->select('b.harga_barang');
$this->db->select('b.status_barang');
$this->db->from('nm_barang b');
$this->db->join('nm_kategori_barang k', 'k.id_kategori = b.id_kategori');
$this->db->where('b.id_barang', $id);
$query = $this->db->get()->row_array();
}
and My Ajax:
$(document).on("click", ".kirimdata", function () {
var id_barang=$(this).data('id');
$.ajax({
type: 'POST',
url:'<?php echo base_url().'Produk/lihatdetail'?>',
data:{ ids: id_barang },
success:function(response){
$(".hasil-data").html(response);
}
});
});
php codeigniter-3
php codeigniter-3
edited Nov 25 '18 at 15:11
TrebuchetMS
3,00511125
3,00511125
asked Nov 25 '18 at 14:02
NewbsWantGeeksNewbsWantGeeks
106
106
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
In the code section
$data['detail'] = $this->produk_m->lihat_detail($this->input->post('ids'));
foreach ($data as $item) {
echo 'Nama Barang :'.$item[0]->nama_barang.'<br>';
}
You want to actually see what you are getting using var_dump() , or print_r() if you want. Try...
$data['detail'] = $this->produk_m->lihat_detail($this->input->post('ids'));
foreach ($data as $item) {
var_dump(); // Inspect the array elements
//echo 'Nama Barang :'.$item[0]->nama_barang.'<br>';
}
I am guessing that you need to either change $data['detail'] to simply $detail OR in the foreach loop change $data to $data['detail']
What you see in the var_dump() output will reveal all...
i change this code to var_dump($data) and the modals show message just 'NULL' , Is there any wrong code in my models or ajax?
– NewbsWantGeeks
Nov 25 '18 at 23:13
1
oke fixed by return the $query and change to $item['nama_barang'] . thanks for helping me hehehe -A-
– NewbsWantGeeks
Nov 25 '18 at 23:16
I am glad you got it sorted out. Cheers.
– TimBrownlaw
Nov 25 '18 at 23:50
add a comment |
if u still want to use
$item[0]->nama_barang
change your query by remove (*_array())
$query = $this->db->get()->row;
thanks for your help, but i already fix that but this suggestion is ok :)
– NewbsWantGeeks
Nov 27 '18 at 12:59
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%2f53468261%2fshow-data-to-modals-get-error-message-in-codeigniter%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
In the code section
$data['detail'] = $this->produk_m->lihat_detail($this->input->post('ids'));
foreach ($data as $item) {
echo 'Nama Barang :'.$item[0]->nama_barang.'<br>';
}
You want to actually see what you are getting using var_dump() , or print_r() if you want. Try...
$data['detail'] = $this->produk_m->lihat_detail($this->input->post('ids'));
foreach ($data as $item) {
var_dump(); // Inspect the array elements
//echo 'Nama Barang :'.$item[0]->nama_barang.'<br>';
}
I am guessing that you need to either change $data['detail'] to simply $detail OR in the foreach loop change $data to $data['detail']
What you see in the var_dump() output will reveal all...
i change this code to var_dump($data) and the modals show message just 'NULL' , Is there any wrong code in my models or ajax?
– NewbsWantGeeks
Nov 25 '18 at 23:13
1
oke fixed by return the $query and change to $item['nama_barang'] . thanks for helping me hehehe -A-
– NewbsWantGeeks
Nov 25 '18 at 23:16
I am glad you got it sorted out. Cheers.
– TimBrownlaw
Nov 25 '18 at 23:50
add a comment |
In the code section
$data['detail'] = $this->produk_m->lihat_detail($this->input->post('ids'));
foreach ($data as $item) {
echo 'Nama Barang :'.$item[0]->nama_barang.'<br>';
}
You want to actually see what you are getting using var_dump() , or print_r() if you want. Try...
$data['detail'] = $this->produk_m->lihat_detail($this->input->post('ids'));
foreach ($data as $item) {
var_dump(); // Inspect the array elements
//echo 'Nama Barang :'.$item[0]->nama_barang.'<br>';
}
I am guessing that you need to either change $data['detail'] to simply $detail OR in the foreach loop change $data to $data['detail']
What you see in the var_dump() output will reveal all...
i change this code to var_dump($data) and the modals show message just 'NULL' , Is there any wrong code in my models or ajax?
– NewbsWantGeeks
Nov 25 '18 at 23:13
1
oke fixed by return the $query and change to $item['nama_barang'] . thanks for helping me hehehe -A-
– NewbsWantGeeks
Nov 25 '18 at 23:16
I am glad you got it sorted out. Cheers.
– TimBrownlaw
Nov 25 '18 at 23:50
add a comment |
In the code section
$data['detail'] = $this->produk_m->lihat_detail($this->input->post('ids'));
foreach ($data as $item) {
echo 'Nama Barang :'.$item[0]->nama_barang.'<br>';
}
You want to actually see what you are getting using var_dump() , or print_r() if you want. Try...
$data['detail'] = $this->produk_m->lihat_detail($this->input->post('ids'));
foreach ($data as $item) {
var_dump(); // Inspect the array elements
//echo 'Nama Barang :'.$item[0]->nama_barang.'<br>';
}
I am guessing that you need to either change $data['detail'] to simply $detail OR in the foreach loop change $data to $data['detail']
What you see in the var_dump() output will reveal all...
In the code section
$data['detail'] = $this->produk_m->lihat_detail($this->input->post('ids'));
foreach ($data as $item) {
echo 'Nama Barang :'.$item[0]->nama_barang.'<br>';
}
You want to actually see what you are getting using var_dump() , or print_r() if you want. Try...
$data['detail'] = $this->produk_m->lihat_detail($this->input->post('ids'));
foreach ($data as $item) {
var_dump(); // Inspect the array elements
//echo 'Nama Barang :'.$item[0]->nama_barang.'<br>';
}
I am guessing that you need to either change $data['detail'] to simply $detail OR in the foreach loop change $data to $data['detail']
What you see in the var_dump() output will reveal all...
answered Nov 25 '18 at 20:46
TimBrownlawTimBrownlaw
3,08521420
3,08521420
i change this code to var_dump($data) and the modals show message just 'NULL' , Is there any wrong code in my models or ajax?
– NewbsWantGeeks
Nov 25 '18 at 23:13
1
oke fixed by return the $query and change to $item['nama_barang'] . thanks for helping me hehehe -A-
– NewbsWantGeeks
Nov 25 '18 at 23:16
I am glad you got it sorted out. Cheers.
– TimBrownlaw
Nov 25 '18 at 23:50
add a comment |
i change this code to var_dump($data) and the modals show message just 'NULL' , Is there any wrong code in my models or ajax?
– NewbsWantGeeks
Nov 25 '18 at 23:13
1
oke fixed by return the $query and change to $item['nama_barang'] . thanks for helping me hehehe -A-
– NewbsWantGeeks
Nov 25 '18 at 23:16
I am glad you got it sorted out. Cheers.
– TimBrownlaw
Nov 25 '18 at 23:50
i change this code to var_dump($data) and the modals show message just 'NULL' , Is there any wrong code in my models or ajax?
– NewbsWantGeeks
Nov 25 '18 at 23:13
i change this code to var_dump($data) and the modals show message just 'NULL' , Is there any wrong code in my models or ajax?
– NewbsWantGeeks
Nov 25 '18 at 23:13
1
1
oke fixed by return the $query and change to $item['nama_barang'] . thanks for helping me hehehe -A-
– NewbsWantGeeks
Nov 25 '18 at 23:16
oke fixed by return the $query and change to $item['nama_barang'] . thanks for helping me hehehe -A-
– NewbsWantGeeks
Nov 25 '18 at 23:16
I am glad you got it sorted out. Cheers.
– TimBrownlaw
Nov 25 '18 at 23:50
I am glad you got it sorted out. Cheers.
– TimBrownlaw
Nov 25 '18 at 23:50
add a comment |
if u still want to use
$item[0]->nama_barang
change your query by remove (*_array())
$query = $this->db->get()->row;
thanks for your help, but i already fix that but this suggestion is ok :)
– NewbsWantGeeks
Nov 27 '18 at 12:59
add a comment |
if u still want to use
$item[0]->nama_barang
change your query by remove (*_array())
$query = $this->db->get()->row;
thanks for your help, but i already fix that but this suggestion is ok :)
– NewbsWantGeeks
Nov 27 '18 at 12:59
add a comment |
if u still want to use
$item[0]->nama_barang
change your query by remove (*_array())
$query = $this->db->get()->row;
if u still want to use
$item[0]->nama_barang
change your query by remove (*_array())
$query = $this->db->get()->row;
answered Nov 27 '18 at 3:58
asnka goasnka go
203
203
thanks for your help, but i already fix that but this suggestion is ok :)
– NewbsWantGeeks
Nov 27 '18 at 12:59
add a comment |
thanks for your help, but i already fix that but this suggestion is ok :)
– NewbsWantGeeks
Nov 27 '18 at 12:59
thanks for your help, but i already fix that but this suggestion is ok :)
– NewbsWantGeeks
Nov 27 '18 at 12:59
thanks for your help, but i already fix that but this suggestion is ok :)
– NewbsWantGeeks
Nov 27 '18 at 12:59
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%2f53468261%2fshow-data-to-modals-get-error-message-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