Not sure if I'm explaining this the wrong way, so I'll try again.
I believe this is how the Model/View/Controller pattern would work.
Model (feedback.php) <- Class file:
Code: Select all
Class Feedback
{
public static function find_by_id($id = 0)
{
global $database;
$result_array = self::find_by_sql("SELECT * FROM " . self::$table_name . " WHERE id = {$id} LIMIT 1");
return !empty($result_array) ? array_shift($result_array) : false;
}
}
Controller (view_details.php):
Code: Select all
<?php
$id = $_GET['fi'];
$feedback = Feedback::find_by_id($id);
?>
<?php include('header.php'); ?>
<?php include('feedback_details.php'); ?>
<?php include('footer.php'); ?>
View (feedback_details.php) <- template file included in view_details.php:
Code: Select all
<p>Name: <?php echo $feedback->name; ?></p>
<p>Email: <?php echo $feedback->email; ?></p>
Once again, my problem is that I'm getting an error stating:
"Undefined variable: feedback
Trying to get property of non-object"
So to my understanding the variable/instance of $feedback from the view_details.php file isn't carrying over into the included feedback_details.php file. How do I do this properly?