CodeIgniter Forums
problem with refresh data - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: problem with refresh data (/showthread.php?tid=33300)

Pages: 1 2


problem with refresh data - El Forum - 08-21-2010

[eluser]cipherz[/eluser]
function index() {
//connect database and retrieve list of item
}

function create() {
// page with form to input data
}

function do_create_item {
// insert data to database
redirect('index');
}

this is my piece of code. I'm using CI2.0. I have a problem when i insert data into database
and redirect back to index page. The new data doesn't appear after the redirect to index page
but i have to press refresh button of browser before the item appear.

Can anybody help what is the problem here?
Thank you in advance.....


problem with refresh data - El Forum - 08-21-2010

[eluser]mi6crazyheart[/eluser]
I think this codes are from u'r controller class file and by using "redirect(‘index’);" u might've wanted to redirect the control to u'r "function index()" of u'r controller file. Am i right... ?


problem with refresh data - El Forum - 08-22-2010

[eluser]cipherz[/eluser]
I'm redirecting to controller/index

This piece of code working in CI 1.7 so im just wondering what could be wrong


problem with refresh data - El Forum - 08-22-2010

[eluser]mi6crazyheart[/eluser]
Ok, if this is the thing the i think this will help u...
Code:
redirect(‘controller-file-name’,'refresh');

for more info: http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html


problem with refresh data - El Forum - 08-22-2010

[eluser]cipherz[/eluser]
It doesnt help with 'refresh' as well =(


problem with refresh data - El Forum - 08-22-2010

[eluser]mi6crazyheart[/eluser]
After using the above redirect code where CI is taking to u ? Can u show u'r controller code also... ?


problem with refresh data - El Forum - 08-23-2010

[eluser]cipherz[/eluser]
<?php

class Member extends Controller {

var $folder = 'member/';
function Member ()
{
parent::Controller();
}

function index()
{
$this->load->model('Member');
$data['list'] = $this->Member->list();
$main['content'] = $this->load->view($this->folder.'index', $data, true);
$this->load->view($this->folder.'layout', $main);
}

function create()
{
$main['content'] = $this->load->view($this->folder.'create', array(), true);
$this->load->view($this->folder.'layout', $main);
}

function do_create_item()
{
$this->load->model('Member');
$data['firstname'] = $this->input->post('firstname');
$data['lastname'] = $this->input->post('lastname');

$this->Member->create($data);
redirect($this->folder.'index');
}
}

index page - list all members
create page - form to input data : firstname and lastname and save button
do_create_item - action to insert member to database

once press save button it redirect to index page but the new record doesnt show up i do have to press refresh button bfore the item appear.


problem with refresh data - El Forum - 08-24-2010

[eluser]mi6crazyheart[/eluser]
Can u say , what's the logic behind of doing this...
Code:
$main[‘content’] = $this->load->view($this->folder.‘index’, $data, true);
$this->load->view($this->folder.‘layout’, $main);



problem with refresh data - El Forum - 08-25-2010

[eluser]cipherz[/eluser]
i have the view file layout.php and index.php in the containing folder. layout.php is kind of wrapper which include menu and footer $main['content'] will hold the content which will change accordingly to each page.


problem with refresh data - El Forum - 08-25-2010

[eluser]mi6crazyheart[/eluser]
Try this & tell me what's happening :

Code:
function index()
  {
      $this->load->model(‘Member’);
      $main[‘content’] = $this->Member->list();  
      $this->load->view('member/layout', $main);
  }