Hello!
So, I have electronic voting system with like/dislike. There is file: evote.php where I select from mysql database candidates and print them.
Looks like this:
AHH, sry, can’t post links :c
Well it looks like this;
CandidateName1 CandidateSurname1 Faculty ‘+’ ‘-’ ‘v’
CandidateName2 CandidateSurname2 Faculty ‘+’ ‘-’ ‘v’
CandidateName3 CandidateSurname3 Faculty ‘+’ ‘-’ ‘v’
CandidateName4 CandidateSurname4 Faculty ‘+’ ‘-’ ‘v’
Like/dislike/skip (in screen +/-/v is with jQuery and after pressing the any of this options - the name disappears.
$("a.vote_up").click(function(){
the_id = $(this).attr('id');
$(this).parent().html("<img src='images/spinner.gif'/>");
$("span#votes_count"+the_id).fadeOut("fast");
$.ajax({
type: "POST",
data: "action=vote_up&id="+$(this).attr("id"),
url: "votes.php",
success: function(msg)
{
$("span#votes_count"+the_id).fadeOut();
$("span#votes_count"+the_id).html(msg);
$("span#votes_count"+the_id).fadeIn();
$("span#vote_buttons"+the_id).remove();
}
});
});
This is function for vote_up, so if you press ‘+’ it goes to votes.php where it finds current votes and then update database +1.
I need count this actions.
Well, actually what i need is: AFTER ALL CANDIDATES ARE DISAPPEARED - IN THIS PAGE (or goes to another, for example: logout.php) and says: THANKS FOR VOTING. But only when there is no candidates left.
So I thought we can count actions in votes.php
$id = $_POST['id'];
$action = $_POST['action'];
if($action == 'vote_up')
{
$votes_up = $cur_votes[0]+1;
$q = "UPDATE candidate SET votes_up = $votes_up WHERE id = $id";
$up++;
}
else if($action == 'vote_down')
{
$votes_down = $cur_votes[1]+1;
$q = "UPDATE candidate SET votes_down = $votes_down WHERE id = $id";
$down++;
}
else if($action == 'vote_neutral')
{
$votes_neutral = $cur_votes[2]+1;
$q = "UPDATE candidate SET votes_neutral = $votes_neutral WHERE id = $id";
$neutral++;
}
$sum = $up + $down + $neutral;
$counter is all my candidate, I count them in while ($row = mysql_fetch_array($r))
And after check if($sum == $counter)
then we go to another page or print, or smth else that says “Thanks for voting”
the problem is: all my printing is in evote.php but $action happens in votes.php, so I don’t know how to make the appearing message :Thanks for voting"
I don’t now jQuery, javaScript, ajax, I found in internet
Hope you can help me