
Untitled
By: a guest on
Apr 19th, 2012 | syntax:
None | size: 0.72 KB | hits: 16 | expires: Never
PHP MVC loop in the view
function displayUsers() {
$sql = $this->pdo->prepare('select * from user');
$sql->execute();
while($row = $sql->fetch())
$results[] = $row;
return $results;
}
while($output) {
foreach($output[$i] as $key => $value)
$data[$key] = $value;
echo $data['email'];
$i++;
}
$data['users'] = $this->MyModel->getusers(); // Getting the users from your model
$data['posts'] = $this->MyModel->getposts(); // Getting the posts from your model
$this->getTemplate('userdisplay', $data); // Get the template userdisplay and pass data
if (count($users) > 0) {
foreach ($users as $person) {
echo $person['email'];
}
}
foreach($output as $row) {
echo $row['email'];
}