title: php mvc fetch data in Database display dropdown
body: <p>How should I add my model into my controller to display the values in drop down ? 
  The error I get: <em>Invalid argument supplied for foreach()</em>
  I didn't use any framework. Just native php. I am new in MVC and PHP please help!</p>
  
  <p>My Controller: </p>
  
  <pre><code>&lt;?php 
    class Index extends Controller {
      function __construct(){
        parent::__construct();
      }
      function index(){
        $landArray = $this-&gt;model-&gt;fetchData();
        $this-&gt;view-&gt;render('index/index');
        var_dump($landArray); // display all row in database
      }
  } 
  </code></pre>
  
  <p>Model:  </p>
  
  <pre><code>&lt;?php
  class Index_Model extends Model {
   function __construct(){
      parent::__construct();
    }
   function fetchData(){
      $selectIsland = $this-&gt;connection-&gt;prepare("SELECT island_id, island 
                                 from island" );
      $selectIsland-&gt;setFetchMode(PDO::FETCH_ASSOC);
      $selectIsland-&gt;execute();
      $islandResult = $selectIsland-&gt;fetchAll();
      return $islandResult;
  
   }
  }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>&lt;select&gt;
      &lt;option value=""&gt;--- Select Island---&lt;/option&gt;
        &lt;?php
              foreach($islandResult as $row){
                echo '&lt;option value="'.$row['island_id'].'"&gt;'.$row['island'].'&lt;/option&gt;';
              endforeach
         }?&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>This is my library View and render method.</p>
  
  <pre><code>&lt;?php
  class View {
   function __construct(){
    }
  public function render($name, $noInclude = false, $landArray){
   if($noInclude == true){
     require 'views/'.$name.'.php';
    }else{
    require 'views/header.php';
    require 'views/'.$name.'.php';
    require 'views/foother.php';
  }
  }
  }
  }
  </code></pre>