title: Codeigniter and database issues
body: <p>Right im new to this and a little out of my depth. Ok so I'm trying to bring in some data and im getting some errors and am I a little confused as to whats going on. </p>
  
  <p>here is the model code: </p>
  
  <pre><code> public function get_webstore_sets($limit, $offset) {
          $this-&gt;db-&gt;select("*");
          $this-&gt;db-&gt;from('st_posts');
          $this-&gt;db-&gt;where("type", "webstore");
          $this-&gt;db-&gt;limit($limit, $offset);
          $this-&gt;db-&gt;order_by('created', 'DESC');
          $query = $this-&gt;db-&gt;get();
          $data = $query-&gt;result_array();
          return$data;
      }
  
      public function count_webstore_sets() {
          $this-&gt;db-&gt;select("*");
          $this-&gt;db-&gt;from('st_posts');
          $this-&gt;db-&gt;where("type", "webstore");
          $this-&gt;db-&gt;order_by('created', 'DESC');
          $query = $this-&gt;db-&gt;get();
          $count = $query-&gt;num_rows();
          return $count;
      }
  </code></pre>
  
  <p>and here is what im trying in the controller:</p>
  
  <pre><code>class Webstore extends MY_Controller {
  
      public function __construct() {
          parent::__construct();
          $this-&gt;load-&gt;model("post");
          $this-&gt;load-&gt;database();
          $this-&gt;load-&gt;helper("url");
  
  
      }
      public function index() {
  
          $this-&gt;data['posts'] = $this-&gt;post-&gt;get_webstore_sets($limit=null, $offset=null); // calling Post model method getPosts()
          $data = array('page_title' =&gt; 'Store', 'video_content');       
          $this-&gt;layout("pages/webstore", $data);
      }
  
  
  }
  </code></pre>
  
  <p>and then bringing it in on HTML:</p>
  
  <pre><code> &lt;?php foreach ($posts as $webstore): ?&gt;
  
  
              &lt;div class="col-md-12" style="height: 225px;"&gt;
                  &lt;div class="col-md-3"&gt;
                      &lt;?php
                      $webstore['images'] = explode(".", $webstore['images']);
                      ?&gt;
                      &lt;img class="thumbnail" width="250px" src="&lt;?php echo $video['images'][1]; ?&gt;.gif"/&gt;
                  &lt;/div&gt;
  
                  &lt;div class="col-md-5"&gt;
                      &lt;h3&gt;&lt;?php echo $webstore['title']; ?&gt;&lt;/h3&gt;
                  &lt;/div&gt;
  
                  &lt;div class="col-md-4 text-center"&gt;
                      Date Added: &lt;?php echo date('d-m-y', strtotime($webstore['created'])) ?&gt;
                       &lt;hr&gt;
                       &lt;a href="http://clips4sale.com/64171/10768027" target="_blank" class="btn btn-primary center-block"&gt;Select or Exclusive to www.Borderlandbound.com&lt;br&gt; Please Visit Our Clips Store For &lt;br&gt;Many More Ultra-Hot Videos Like This&lt;/a&gt;
  &lt;hr&gt;
                  &lt;/div&gt;
  
              &lt;/div&gt;
  
              &lt;hr&gt;
          &lt;?php endforeach; ?&gt;
  </code></pre>
  
  <p>I know the connection is ok as the site is bringing in data from else where.</p>
  
  <p>and this is the error im getting :</p>
  
  <pre><code>Severity: Notice
  
  Message: Undefined variable: posts
  
  Filename: pages/webstore.php
  
  Line Number: 39
  
  A PHP Error was encountered
  
  Severity: Warning
  
  Message: Invalid argument supplied for foreach()
  
  Filename: pages/webstore.php
  
  Line Number: 39
  </code></pre>
  
  <p>I have blanked out the file path just in case ;) Edited for the above errors</p>