This code I have been working on for weeks have givin me so much trouble.
What is is suppose to do is pull the userpicks, the winners, the point values, and the users current points all from the DB.
Well it does that just fine, then is checks to see if the winners match the userpicks, and if they do add points to there current point value for that round, and add it to the DB.
Well it is not updating the users row in the DB under userpoints
I set the default values in the userpoints to all to 0 the structure is:
Username | total | rnd1 | rnd2 | rnd3 | rnd4 | rnd5 | champ
----------------------------------------------------------
Lamez | 0 | 0 | 0 | 0 | 0 | 0 | 0
That is the default when a user registers, but the code does not add points to the DB, why?
The code is very consistent so once you have seen one IF statment, you have seen 'em all.
Code:
<?php
include("style/include/session.php");
include ("style/include/cons/head.php");
echo '<div class="box">';
$user = "Lamez";
/*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'];
/*$result=mysql_query('SELECT * FROM users');
while($row=mysql_fetch_array($result)){
$user=$row['user'];*/
if ( $win['1'] == $pick['a1'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['2'] == $pick['a2'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['3'] == $pick['a3'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['4'] == $pick['a4'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['5'] == $pick['a5'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['6'] == $pick['a6'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['7'] == $pick['a7'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['8'] == $pick['a8'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['9'] == $pick['b1'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['10'] == $pick['b2'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['11'] == $pick['b3'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['12'] == $pick['b4'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['13'] == $pick['b5'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['14'] == $pick['b6'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['15'] == $pick['b7'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['16'] == $pick['b8'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['17'] == $pick['c1'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['18'] == $pick['c2'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['19'] == $pick['c3'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['20'] == $pick['c4'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['21'] == $pick['c5'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['22'] == $pick['c6'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['23'] == $pick['c7'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['24'] == $pick['c8'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['25'] == $pick['d1'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['26'] == $pick['d2'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['27'] == $pick['d3'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['28'] == $pick['d4'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['29'] == $pick['d5'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['30'] == $pick['d6'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['31'] == $pick['d7'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
if ( $win['32'] == $pick['d8'] )
{
$total = $value + $total;
$rnd1 = $value + $rnd1;
mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'");
}
//} //End Loop
print '</div>';
include ("style/include/cons/foot.php");
?>