Lamez Posted March 4, 2008 Share Posted March 4, 2008 Sorry to bother you guys once more, but my script is not working at all, it is suppose to check to see if the user picked the winner, if so add the points, from the points table. Well I tested it, I made the user pick the winner, and it does not add the points at all. Here is a code snippet, could someone read over it and tell me if I have any syntax errors. <?php $result=mysql_query('SELECT * FROM userpoints'); while($row = mysql_fetch_array($result)){ $user = $row['username']; /*Pull Winners for Round 1*/ $q = mysql_query("Select * from `rnd1_win`"); $win=mysql_fetch_array($q); /*Pull User Picks for Round 1*/ $q = mysql_query("Select * from `rnd1` where `username` = '$user'"); $pick=mysql_fetch_array($q); /*Pull Point Values for Round 1*/ $q = mysql_query("Select rnd1 from `points`"); $point=mysql_fetch_array($q); $value = $point['rnd1']; /*Pull User Points for Round 1*/ $q = mysql_query("Select `username`, `total`, `rnd1` from `userpoints` Where `username` = '$user'"); $usrpoint=mysql_fetch_array($q); $total = $usrpoint['total']; $rnd1 = $usrpoint['rnd1']; if (!$a1 == ("emp")){ if ($win['1'] = ($pick['a1'])){ $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'")or die(mysql_error()); } } } ?> Breaking Down the If Statement if (!$a1 == ("emp")){ check to see if the postdata is equal to emp, and if not continue the script, if so skip this portion and continue to next if. if ($win['1'] = ($pick['a1'])){ check to see if the user picked the winner, if so continue to add points $total = $value + $total; take value from point table, and add it to the total, then get a new total $rnd1 = $value + $rnd1; take the value from the point table, and add it to round one (rnd1) then get new rnd1 mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'")or die(mysql_error()); update the DB } } Close if statements -Thanks Guys! Quote Link to comment https://forums.phpfreaks.com/topic/94190-need-some-help-on-ifs-and-else/ Share on other sites More sharing options...
Lamez Posted March 4, 2008 Author Share Posted March 4, 2008 I think I fixed it, I just changed the position of the ! would this work? <?php if ($a1 != ("emp")){ if ($win['1'] = ($pick['a1'])){ $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'")or die(mysql_error()); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/94190-need-some-help-on-ifs-and-else/#findComment-482462 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.