Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 19th, 2012  |  syntax: None  |  size: 0.72 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. PHP MVC loop in the view
  2. function displayUsers() {
  3. $sql = $this->pdo->prepare('select * from user');
  4. $sql->execute();
  5. while($row = $sql->fetch())
  6.     $results[] = $row;
  7. return $results;
  8. }
  9.        
  10. while($output) {
  11.     foreach($output[$i] as $key => $value)
  12.         $data[$key] = $value;
  13.     echo $data['email'];
  14.     $i++;
  15. }
  16.        
  17. $data['users'] = $this->MyModel->getusers(); // Getting the users from your model
  18. $data['posts'] = $this->MyModel->getposts(); // Getting the posts from your model
  19. $this->getTemplate('userdisplay', $data); // Get the template userdisplay and pass data
  20.        
  21. if (count($users) > 0) {
  22.     foreach ($users as $person) {
  23.         echo $person['email'];
  24.     }
  25. }
  26.        
  27. foreach($output as $row) {
  28.    echo $row['email'];
  29. }