i have this code
<?php
$votes_query=mysql_query("select * from votes where CandidateID='$id'");
$vote_count=mysql_num_rows($votes_query);
echo $vote_count;
?>
which fetches individual *ID*s from my votes
table.
I need a code which can help fetch the sum of specific *ID*s.
Lets say, I have ID-205
and ID-209
in my table.
<?php
$ids = array('205','209');
$votes_query=mysql_query("select * from votes where CandidateID IN($ids) ");
$vote_count=mysql_num_rows($votes_query);
echo $vote_count;
?>
Put all ID's in an array & Use IN Clause of mysql.
<?php
$ids = array('205','209');
$sql "SELECT SUM(field_score) AS vote_score FROM votes WHERE CandidateID IN ($ids)";
$vote_score = mysql_query($sql);
echo $vote_score;
?>