我目前已經實現了一個點擊計數器,如果該值設置爲空,並且您點擊它將更新爲一個的鏈接。但是當它第二次點擊時,它不會更新它保持爲一個。如何使點擊計數器在點擊時多次更新?
public function getUpdateClick($Id) {
$Id=DB::escape_string($Id);
$i=1;
$click=0;
$click=$click+$i;
$updatesArray=array('clicks'=>$click);// the column which is going to be updated
$this->setTable('pages'); //setting the table name
$where="id=$Id";
$result=$this->update($updatesArray,$where); // query executed
}
爲什麼當你在1之後立即加1時設置'$ click = 0'? –
因爲您從不使用'$ set =「click = click + 1」;'但總是'$ click = 0 + 1;'。 – dfsq
因爲我一直收到未分配變量的錯誤消息 – philp