私はあなたがCIで、あるいはPHPで新しく追加されたと思います(私はこれは間違っていることを知っています)。しかし、その罰金。なぜ私たちはstackoverflowが必要なのですか?
最初に、あなたはまだログインしていないguest /匿名ではなく、彼または彼女の名前の入力を提出していないと思います。それ以外の場合、コードのワークフローは異なります。
あなたのデシベルで表
table
#calon_table => profile of governor or person who will voted
id [int auto_increment]
name [varchar]
#user_table = profile of user who will vote
id [int auto_increment]
name [varchar]
password, avatar, and another information here
#vote_table = table to store vote result
id_user [int ,PRIMARY KEY, foreign key of user_table.id] //while this set as Primary Key , you are never get duplicate user for voting
id_calon [int ,foreign key of calon_table.id]
、コードは次のようになります。
function vote_calon(){
$id_calon = $this->input->post('id_calon'); //example : 2
$id_user = $this->input->post('voted'); //example: 324234
$data = array(
'id_user' => $id_user,
'id_calon' => $id_calon
);
$where = array(
'id_user' => $id_user //this is where clause to keep 1 user only can vote 1 governor
);
$check = $this->db->where('vote_table', $where);
if($check->num_rows() > 0)
{
echo "you already use your vote"; //this is for make sure user cant vote more than 1
//OR u can try update: $this->db->update('vote_table', $data, $where);
}
else
{
//insert data
$this->db->insert('vote_table', $data);
}
redirect('voter/voter_sukses');
}
あなたはインドネシアからあるので、多分あなたはWA kosong LAPANサトゥ・ドゥアsmbilan kosong kosong ENAM LAPANを経由して私に尋ねることができますlapan sembilan kosong
あなたの質問は何ですか? –
あなたのsqlクエリが間違っている(モデルコードを表示しないで)ベスト – ahmad
私は村の頭を選ぶために投票システムを作りたいと思っており、各ユーザは一度だけ投票できました。 私はこの機能を助けることができますか? また、ユーザーのステータスを変更する機能がステータス1〜0の投票を行っています –