view:
<?phpforeach($row as $b):?>
<?php echo $b->Product_Name ?></h3>
<?php echo $b->Price ?></p>
</div>
<?php if ($b->Option_name):?>
<?php echo form_label($b->Option_name, 'option_'.$b->Product_ID ); ?>
<?php echo form_dropdown(
$b->Option_name,
$b->Option_value,
NULL,
'Product_ID= " option_' .$b->Product_ID. ' " '
);?>
<?php endif; ?>
controller:
public function product_detail($Product_ID){
$this->load->model('model_products');
$data['row']= $this->model_products->get_detail($Product_ID);
$this->load->view('product_detail',$data);
}
model:
function get_detail($Product_ID){
$this->db->from('products');
$this->db->where('Product_ID',$Product_ID);
$query= $this->db->get('');
if ($query->num_rows()==1) {
foreach($query->result() as $row){
$data[]=$row;
}
}
return $data;
}
codeignitor
i m get warning : Invalid argument supplied for foreach() I thing it is dropdown
Nabeel_2
0
Newbie Poster
Recommended Answers
Jump to Postcan you do ?
print_r($data['row']);
Jump to Postcan you change and test your model with this code?
function get_detail($Product_ID) { $this->db->from('products'); $this->db->where('Product_ID',$Product_ID); $query= $this->db->get(''); if ($query->num_rows() >0 ) { return $query->result(); } /// return false; }
this
return $query->result();
allows you to access the $row in view as object.,
…
All 6 Replies
veedeoo
474
Junior Poster
Featured Poster
Nabeel_2
0
Newbie Poster
veedeoo
474
Junior Poster
Featured Poster
veedeoo
474
Junior Poster
Featured Poster
Nabeel_2
0
Newbie Poster
pzuurveen
90
Posting Whiz in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.