Welcome Guest, Not a member yet? Register   Sign In
[Closed] Rows From Database Do Not Show After Refresh Page
#1

[eluser]riwakawd[/eluser]
Hi I just working on my model for my stores url and name. Every time I add new row in database and the refresh page will not show the updated information or any new rows.

I need it to be able to show all new and updated information.


A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: store/store_list.php

Line Number: 16


Model
Code:
public function getStores() {
        $this->db->select('*');

     $this->db->from('store');

     $this->db->where('store_id');

     $this->db->order_by('url', ' asc');

     $query = $this->db->get();
    
    if ($query->num_rows() > 0) {
     return true;
    } else {
     return false;
    }
}
View

Code:
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
  &lt;form action="" method="post" enctype="multipart/form-data" &gt;
  <table class="table table-striped table-hover">
  <tbody>
  &lt;?php foreach($stores as $store) : ?&gt;
        <tr>
            <td>&lt;?php echo $store['name']; ?&gt;</td>
            <td>&lt;?php echo $store['url'] ;?&gt;</td>
        </tr>
      &lt;?php endforeach; ?&gt;
      </tbody>
      </table>
  &lt;/form&gt;
</div>
</div>

Controller
Code:
&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


class Store extends MX_Controller {

public function __construct() {
      parent::__construct();
       $this->lang->load('admin/store/store', 'english');
   $this->lang->load('admin/english', 'english');
   $this->load->driver('cache');
   if ($this->session->userdata('user_id') == true) {
    return true;
   } else {
    redirect('admin');
   }
   }

public function index() {

  $this->document->setTitle($this->lang->line('heading_title'));
  $this->getList();

}


public function getList() {
  

  $data['breadcrumbs'] = array();

  $data['breadcrumbs'][] = array(
   'text' => $this->lang->line('text_home'),
   'href' => site_url('admin/dashboard')
  );

  $data['breadcrumbs'][] = array(
   'text' => $this->lang->line('heading_title'),
   'href' => site_url('admin/store')
  );

  $data['heading_title'] = $this->lang->line('heading_title');

  $data['text_no_results'] = $this->lang->line('text_no_results');
  $data['text_confirm'] = $this->lang->line('text_confirm');

  $data['column_name'] = $this->lang->line('column_name');
  $data['column_url'] = $this->lang->line('column_url');
  $data['column_action'] = $this->lang->line('column_action');

  $data['button_insert'] = $this->lang->line('button_insert');
  $data['button_edit'] = $this->lang->line('button_edit');
  $data['button_delete'] = $this->lang->line('button_delete');

  $data['button_save'] = $this->lang->line('button_save');
  $data['button_cancel'] = $this->lang->line('button_cancel');

  $this->load->model('admin/store/model_store');

  $data['stores'] = $this->model_store->getStores();

  $data['cancel'] = site_url('admin/dashboard');

  return $this->load->view('store/store_list', $data);
}


}
#2

[eluser]Tim Brownlaw[/eluser]
Why Closed?
#3

[eluser]InsiteFX[/eluser]
Good question Tim.
#4

[eluser]riwakawd[/eluser]
[quote author="Tim Brownlaw" date="1409991349"]Why Closed?[/quote]

Because I posted this topic before I talked to you on Skype. And Can not delete post.
#5

[eluser]riwakawd[/eluser]
[quote author="InsiteFX" date="1409991954"]Good question Tim.
[/quote]

I spoke to Tim on Skype and had a good chat. I posted topic before I could get hold of him. Wish there was away to get rid of unwanted post.




Theme © iAndrew 2016 - Forum software by © MyBB