Jump to content

Helping Update Multiple Users


kybaker

Recommended Posts

Hey all,

 

To get to the point....I need to be able to update multiple users based on whether they selected the correct answer or not. As of right now my code runs through and selects the first user and if they are correct it updates their income to the correct amount. This does not happen for multiple users... its stopping my iteration after the first person.

 

Anyone know what I'm doing wrong?

        if($result) {
                //pull information from bet where bet is on right game
                $income_qry = "SELECT * from makeBets where sport_event='$game_id'";
                $income_results = mysql_query($income_qry)
                        or die("Query failed");
                while($incomeupdate = mysql_fetch_array($income_results)){
                        $bet_amt = $incomeupdate['bet_amt'];
                        $selection = $incomeupdate['selection'];
                        $member = $incomeupdate['member_id'];

					//Query to get original income
					$iqry = "SELECT income FROM users WHERE member_id ='$member'";
					$income_results = mysql_query($iqry);
					$income_array = mysql_fetch_array($income_results);
					$income = $income_array['income'];


					//if selection is a winner; update income
                                                if($selection==$winner){
							//add original income + (bet_amt *2)
							$new_income  = $income + $bet_amt + $bet_amt;
                                                                $qry_update_income = "UPDATE users SET income='$new_income' WHERE member_id ='$member'";
                                                                $update_results = mysql_query($qry_update_income)
                                                                       or die("Update Income Query Failed");
                                                }
                                                else {
                                                       continue;
                                                }
                                }
			header("location: update-games-success.php");
        		        exit();
               }
	else{
		echo "Update Game Winner Query Failed";
	}

 

Link to comment
https://forums.phpfreaks.com/topic/200168-helping-update-multiple-users/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.