12-27-2015, 03:25 AM
(This post was last modified: 12-27-2015, 02:29 PM by wolfgang1983.)
On my forum I am learning to make I have made a reputation vote model.
I would like to know. When forum_user_reputation get's to 0 from been voted down $this->input->post('vote_down') to it then it should stop there.
Currently if the question gets down voted still the forum_user_reputation will go into negative -2 but I need to make it stop at 0
How could I make suitable changes to my function update_forum_question()
Thanks for you advice
I would like to know. When forum_user_reputation get's to 0 from been voted down $this->input->post('vote_down') to it then it should stop there.
Currently if the question gets down voted still the forum_user_reputation will go into negative -2 but I need to make it stop at 0
How could I make suitable changes to my function update_forum_question()
PHP Code:
public function update_forum_question() {
$current_votes = $this->get_question_reputation();
if ($this->input->post('vote_up') == TRUE) {
$sum_total = $current_votes + $this->input->post('vote_up');
$data = array(
'forum_question_reputation' => $sum_total
);
$this->db->where('forum_question_id', '1');
$this->db->where('forum_user_id', '1');
$this->db->update('forum_questions', $data);
$forum_user_reputation = $this->get_forum_user_reputation();
$forum_reputation = $forum_user_reputation + 5;
$data = array(
'forum_reputation' => $forum_reputation
);
$this->db->where('forum_user_id', '1');
$this->db->update('forum_user', $data);
} elseif ($this->input->post('vote_down') == TRUE) {
$sum_total = $current_votes - $this->input->post('vote_down');
$data = array(
'forum_question_reputation' => $sum_total
);
$this->db->where('forum_user_id', '1');
$this->db->where('forum_question_id', '1');
$this->db->update('forum_questions', $data);
$form_votes = $current_votes - 2;
$data = array(
'forum_reputation' => (int)$form_votes
);
$this->db->where('forum_user_id', '1');
$this->db->update('forum_user', $data);
}
}
Thanks for you advice
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!