We are facing a very weird problem and i have tried looking for a solution but found none. We built a site in core php and it has a rotating banner/ slider that displays an amount that changes when a user purchases something on the site.
For example, the site sale is $1000 and every time a user makes a purchase that figure on the banner changes from $1000 to may be $1050 and so on.
Now the problem that is being faced is that sometimes (not all the times) when we do a page refresh, the amount on the banner increments by a specific amount say $25. So if you refresh the page 4 times, the amount would increase by $100.
Could someone please please suggest what could be wrong here?
Sorry for not adding the code earlier.
This code is in codeigniter
Controller file say home.php code
$count_Values = $this->home_model->countHome();//check if there any
update in order table ie if any purchase made or not
$count_Values1 =$this->home_model->getTotalDonation();//get total
doantion amount from db
$updateDonation =$this->home_model->updateDonationDetails($count_Values);//update
amount on db
$data['count'] = number_format($count_Values1,0);//for view
Model file say home_model.php
/*
@Function name:countHome
@Purpose :Used to count donation in order table
*/
public function countHome()
{
$this->db->select('modify_date');
$this->db->from('tbl_common');
$this->db->where('id',1);
$query1=$this->db->get();
$result=$query1->row();
$date =$result->modify_date;
$query=$this->db->query("select sum(pac_donation_to_owner) as totalpac
from tbl_order where order_status='1' and order_createddate >
'$date'");
$total = $query->row()->totalpac;
return ($total);
}
/*
@Function name:getTotalDonation
@Purpose :get total donation
*/
public function getTotalDonation()
{
$this->db->select('value');
$this->db->from('tbl_common');
$this->db->where('id',1);
$query=$this->db->get();
$result=$query->row();
return $result->value;
}
/*
@Function name:updateDonationDetails
@Purpose:for update total donation in tbl_common
*/
public function updateDonationDetails($values)
{
$this->db->select('value');
$this->db->from('tbl_common');
$this->db->where('id',1);
$query =$this->db->get();
$result =$query->row();
$updateValue = $result->value;
$data['modify_date'] = date('Y-m-d h:i:s');
$data['value'] =$values+$updateValue;
$this->db->where('id',1);
$this->db->update('tbl_common', $data);
}
View.php file
<?php echo $count; ?>
Thanks