Welcome Guest, Not a member yet? Register   Sign In
On Update/Delete data is not showing properly
#1

[eluser]Was[/eluser]
Hello Friends,

i m using CI 2.1.0. i have done admin section for one of my website. when i m deleting content from admin its get deleted and after delete i m redirecting it with redirect('admin/myfunction', 'refresh');.its redirecting properly but showing the deleted data also for this every time i need to refresh manually and then it will not showing the deleted data. i m not getting what's wrong here,any one guide me how to solve this ?

thanx

Was
#2

[eluser]the_unforgiven[/eluser]
remove the "refresh" for the redirect that should work!
#3

[eluser]Was[/eluser]
Hello thanx for the reply,
i have tried with removing the 'refresh'. its deleted the data but cant redirect anywhere and i have tried with keeping '' in place of refresh it will redirect the page but still showing the deleted data and i need to refresh the page manually again to see the result.is there any other way to solve this?

thanx
Was
#4

[eluser]soijiro[/eluser]
I'm not sure what's your problem.
But for the best suggestion, you can show us what's in your controller.
#5

[eluser]Was[/eluser]
Hello, thanx for the reply

here is the my code which i m using

function deleteproduct($id)
{
if($this->session->userdata('admin_id')!='')
{
if($id)
{
$this->common->db_delete('product','id',$id);
redirect('admin/products', 'refresh');
}
else
{
redirect('admin/products', 'refresh');
}
}
else
{
redirect('admin', 'refresh');
}
}

So its deleting the product and redirecting on listing page but still the deleted item is appearing on my listing page and i need to refresh the page manually then the deleted item is disappear from listing page. so this is the problem.

thanx
Was
#6

[eluser]soijiro[/eluser]
did you working with cache?
products method code please.
#7

[eluser]Was[/eluser]
Hello,
here is the my products listing code and i m not using any cache method.

function products($page=0)
{
$config['base_url'] = base_url().'index.php/admin/products/';
$config['total_rows'] =$this->common->numberofrecord("*","products","");
$config['per_page'] =30;
$config['uri_segment']=3;
$this->pagination->initialize($config);
$data_common=$this->common->fetchdata("*","products","","order by id desc",$page,$config['per_page']);
$data['data_common']=$data_common;
if($this->session->userdata('admin_id')!='')
{
$this->load->view('admin/header');
$this->load->view('admin/products',$data);
$this->load->view('admin/footer');
}
else
{
redirect('admin','');
}
}

and this is the common query which i have written in models for fetching the data

function fetchdata($fieldname,$tblname,$where,$orderby,$page,$max)
{
$query=$this->db->query("select ".$fieldname." from ".$tblname." ".$where." ".$orderby." limit $page,$max");
$data=$query->result_array();
return $data;
}

thanx
Was
#8

[eluser]soijiro[/eluser]
Hi man,
i'm not sure if this solve your problem, but you can try.

change this
Code:
$data_common=$this->common->fetchdata("*","products","","order by id desc",$page,$config['per_page']);
to
Code:
$data_common=$this->common->fetchdata("*","products","","order by id desc",$config['per_page'],$page);

#9

[eluser]soijiro[/eluser]
Are you sure your pagination work perfectly?

uri
Code:
index.php/admin/products/$id

your uri_segment on pagination config should be :
Code:
$config['uri_segment'] = 3
#10

[eluser]Was[/eluser]
Sorry dear its not working Smile




Theme © iAndrew 2016 - Forum software by © MyBB