I'm trying to display a database of items, the database (using mySQL) and PHPStorm are 100% linked. When I run the site the column names are displayed and it says that there is an error in the header of foreach loop (code from phtml file):
<?php
foreach ($view->productDataSet as $productData) {
echo '<td>'.$productData->getProductID().
'</td><td>'.$productData->getProductName().
'</td><td>'.$productData->getProductPrice().
'</td><td>'.$productData->getProductDesc().
'</td><td>'.$productData->getProductManufacturer().
'</td><td>'.$productData->getQuantity().
'</td><td>'.'<img src="images/'.$productData->getPhotoName().'" alt="no picture"/>'.
'</td> </td>';
}
?>
'productDataSet' is highlighted and reads "Field productDataSet not found in productDataSet(php file)", also all get methods are highlighted and display that they cannot be found. They are situated in my productData.php file. Sorry if this is messy and I don't explain this very well. I'm new to PHP.
Code for ProductData:
class ProductData {
protected $_id, $_product_name, $_product_price, $_product_desc, $_product_manufacturer, $_quantity_in_stock, $_photo_name;
public function __construct($dbRow) {
$this->_id = $dbRow['id'];
$this->_product_name = $dbRow['product_name'];
$this->_product_price = $dbRow['product_price'];
$this->_product_desc = $dbRow['product_desc'];
$this->_product_manufacturer = $dbRow['product_manufacturer'];
$this->_quantity_in_stock = $dbRow['quantity_in_stock'];
$this->_photo_name = $dbRow['photo_name'];
}
public function getProductID() {
return $this->_id;
}
public function getProductName() {
return $this->_product_name;
}
public function getProductPrice() {
return $this->_product_price;
}
public function getProductDesc() {
return $this->_product_desc;
}
public function getProductManufacturer() {
return $this->_product_manufacturer;
}
public function getQuantity() {
return $this->_quantity_in_stock;
}
public function getPhotoName() {
return $this->_photo_name;
}
}