mustish1
asked on
Error in method
Can you please help me in that error.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
class CoffeeEntity
{
public $id;
public $name;
public $type;
public $price;
public $roast;
public $country;
public $image;
public $review;
function __construct($id, $name, $type, $price, $roast, $country, $image, $review) {
$this->id = $id;
$this->name = $name;
$this->type = $type;
$this->price = $price;
$this->roast = $roast;
$this->country = $country;
$this->image = $image;
$this->review = $review;
}
}
?>
ASKER
<?php
require 'Controller/CoffeeController.php';
$coffeeController = new CoffeeController();
if(isset($_POST['types']))
{
//Fill page with coffees of the selected type
$coffeeTables = $coffeeController->CreateCoffeeTables($_POST['types']);
}
else
{
//Page is loaded for the first time, no type selected -> Fetch all types
$coffeeTables = $coffeeController->CreateCoffeeTables('%');
}
//Output page data
$title = 'Coffee overview';
$content = $coffeeController->CreateCoffeeDropdownList(). $coffeeTables;
include 'Template.php';
?>
see if you have declared "CoffeeEntity" in Controller/CoffeeControlle r.php ?
ASKER
<?php
require ("Model/CoffeeModel.php");
//Contains non-database related function for the Coffee page
class CoffeeController {
function CreateCoffeeDropdownList() {
$coffeeModel = new CoffeeModel();
$result = "<form action = '' method = 'post' width = '200px'>
Please select a type:
<select name = 'types' >
<option value = '%' >All</option>
" . $this->CreateOptionValues($coffeeModel->GetCoffeeTypes()) .
"</select>
<input type = 'submit' value = 'Search' />
</form>";
return $result;
}
function CreateOptionValues(array $valueArray) {
$result = "";
foreach ($valueArray as $value) {
$result = $result . "<option value='$value'>$value</option>";
}
return $result;
}
function CreateCoffeeTables($types)
{
$coffeeModel = new CoffeeModel();
$coffeeArray = $coffeeModel->GetCoffeeByType($types);
$result = "";
//Generate a coffeeTable for each coffeeEntity in array
foreach ($coffeeArray as $key => $coffee)
{
$result = $result .
"<table class = 'coffeeTable'>
<tr>
<th rowspan='6' width = '150px' ><img runat = 'server' src = '$coffee->image' /></th>
<th width = '75px' >Name: </th>
<td>$coffee->name</td>
</tr>
<tr>
<th>Type: </th>
<td>$coffee->type</td>
</tr>
<tr>
<th>Price: </th>
<td>$coffee->price</td>
</tr>
<tr>
<th>Roast: </th>
<td>$coffee->roast</td>
</tr>
<tr>
<th>Origin: </th>
<td>$coffee->country</td>
</tr>
<tr>
<td colspan='2' >$coffee->review</td>
</tr>
</table>";
}
return $result;
}
}
?>
see if you have declared "CoffeeEntity" in Controller/CoffeeController.php ?
see if you found that in Model/CoffeeModel.php?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank You.
pls share your codes in coffee.php for troubleshooting.