I'm trying to get data userid
and votes
from table polls
and then update users
table, but can't figure out how I can do it.
When I implode ids, i got userid's like
293,934
But I dont know who I can get all userid's and their votes from table and update users table....
$pollid = 0 + $_GET["pollid"];
$poll_res = mysql_query("SELECT userid FROM polls WHERE pollid = $pollid");
$idss = array();
while($poll_row = mysql_fetch_array($poll_res)) {
$idss[] = 0 + $poll_row['userid'];
}
$implode = implode(',', $idss);
$get_votes = mysql_query("SELECT votes FROM polls WHERE pollid = $pollid AND userid In($implode)");
// How I can update multilple user (rows) who are voted (found user votes and id from POLLS table) ?
// I just add $votes and $userid here so you know what I want to do....
mysql_query("UPDATE users SET total_votes = votes + $votes WHERE id = $userid");