[eluser]freshigniter[/eluser]
hello genius men,am really happy to post here as i always get a lot of responses within a short span of time , which indeed helps me a lot. :cheese: so hers is another bug for you guys.
have a happy Helping :bug:
about my project: its an online store, with the main categories displayed on login page, the user hover the mouse over these categories to get subcategories[sc]. if he clicks on the SC he will be directed to a page where all the products with that SCs will be displayed.
MY PROBLEM IS : when i click those products the controller will take me to the URL[written below] with product id, with the following error.
A PHP Error was encountered
in the URL :http://localhost/business/index.php/detail/products/12
controller:detail
Code:
function products($id='')
{
$this->load->model('Product_model');
$data['getproductdetail']=$this->Product_model->get_productdetail($id);
$this->load->view('detail/product');
}
modelroduct_model
Code:
function get_productdetail($id)
{
$this->db->select('*');
$this->db->from('product');
$this->db->where('id',$id);
$query=$this->db->get();
return $query->row();
}
VIEW:product.php
Code:
<?php
foreach($getproductdetail as $product)
{ echo $product->product_name; echo $product->description; }
?>
DATABASE NAME: business
TABLE NAME:product
------------------------------------------------------------------------------------
id |product_name|category_id| subcategory_id| description | price
------------------------------------------------------------------------------------
8 |home | 14 | 14 |build home within budget | $1000
7 |antivirus | 12 | 9 |protects all your digital data| $500
6 |rice1 | 1 | 1 |awesome rice,easy to cook | $50/kg
------------------------------------------------------------------------------------
RESULT:
Home
PRODUCTS
----------------------------------------
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: getproductdetail
Filename: detail/product.php
Line Number: 12
----------------------------------------
----------------------------------------
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: detail/product.php
Line Number: 12
----------------------------------------
please let me know where am going wrong.