problem with refresh data |
[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.....
[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... ?
[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
[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-gui...elper.html
[eluser]mi6crazyheart[/eluser]
After using the above redirect code where CI is taking to u ? Can u show u'r controller code also... ?
[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.
[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);
[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.
[eluser]mi6crazyheart[/eluser]
Try this & tell me what's happening : Code: function index() |
Welcome Guest, Not a member yet? Register Sign In |