![]() |
Codeigniter Vote Candidate System - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Codeigniter Vote Candidate System (/showthread.php?tid=66565) |
Codeigniter Vote Candidate System - bagusbal - 11-04-2016 Hai, i'm new in codeigniter and i want to create a vote candidate system as my thesis. I want to create function each user can vote 1 candidate only, and after user vote the candidate the user status will be change from '1' to '0'. 1= its mean user can vote 0= its mean user can't vote. i already try to create it, but doesnt work. Can someone help me ? Big thanks from me. Here is my code. PHP Code: <?php Model PHP Code: <?php and here is my view, from user page. PHP Code: <!doctype html> Thanks for any help. Gus bala RE: Codeigniter Vote Candidate System - sv3tli0 - 11-05-2016 If 1 user can vote just once for 1 candidate, I think that it will be easier for you instead of vote status 0|1, to have field voted_for - which will keep the candidate ID .. So when its NULL or 0 this mean that the user has not voted yet.. In case that such votes will be not just once per your site life it will be better if you do that in a separate table "user_votes" With 3 fields : User_id : the id of the one who set vote, Candidate_id : the id of the candidate Vote_id : the id of the Vote (this field will separate each voting campaign as: summer2016, winter2017 and etc..) In this case you can add and unique index for ( user_id + vote_id ) which will limit users to vote just once per campaign. RE: Codeigniter Vote Candidate System - bagusbal - 11-06-2016 (11-05-2016, 01:52 AM)sv3tli0 Wrote: If 1 user can vote just once for 1 candidate, I think that it will be easier for you instead of vote status 0|1, to have field voted_for - which will keep the candidate ID .. Thanks for your suggestion. But my problem is how to create a vote function i'm stuck on it. I already create a separate table for user. |