RootDev Posted July 27, 2009 Share Posted July 27, 2009 <?php /*SQL Creditenials*/ $host = "localhost"; $user = "root"; $password = ""; $database = "gbwc"; $link = mysql_connect($host,$user,$password); if(!$link){ mysql_error(); die();} mysql_select_db($database) or mysql_error() and die(); $gp = if($gp>=1100) { $newlevel="woodaxe";} if($gp>=1200) { $newlevel="doublewoodaxe";} if($gp>=1500) { $newlevel="stoneaxe";} if($gp>=1800) { $newlevel="doublestoneaxe";} if($gp>=2300) { $newlevel="metalaxe";} if($gp>=2800) { $newlevel="doublemetalaxe";} if($gp>=3500) { $newlevel="silveraxe";} if($gp>=4200) { $newlevel="doublesilveraxe";} if($gp>=5100) { $newlevel="goldaxe";} if($gp>=6000) { $newlevel="doublegoldaxe";} if($gp>=6900) { $newlevel="doublesmetalaxe";} if($gp>=14139) { $newlevel="doublesmetalaxeplus";} if($gp>=8438) { $newlevel="doublessilveraxe";} if($gp>=10482) { $newlevel="doublessilveraxeplus";} if($gp>=17691) { $newlevel="doublesgoldaxe";} if($gp>=24943) { $newlevel="doublesgoldaxeplus";} if($gp>=31668) { $newlevel="violethole";} if($gp>=41654) { $newlevel="sapphirehole";} if($gp>=62716) { $newlevel="redrubyhole";} if($gp>=139555) { $newlevel="diamondhole";} if($gp>=305621) { $newlevel="bluedragon";} if($gp>=370311) { $newlevel="reddragon";} if($gp>=412234) { $newlevel="silverdragon";} if($gp>=1000000) { $newlevel="halloffame";} if($newlevel=="woodaxe") { mysql_query("UPDATE game SET TotalGrade='18',SeasonGrade='18' WHERE auth = '1'"); } if($newlevel=="doublewoodaxe") { mysql_query("UPDATE game SET TotalGrade='17',SeasonGrade='17' WHERE auth = '1'"); } if($newlevel=="stoneaxe") { mysql_query("UPDATE game SET TotalGrade='16',SeasonGrade='16' WHERE auth = '1'"); } if($newlevel=="doublestonaxe") { mysql_query("UPDATE game SET TotalGrade='15',SeasonGrade='15' WHERE auth = '1'"); } if($newlevel=="metalaxe") { mysql_query("UPDATE game SET TotalGrade='14',SeasonGrade='14' WHERE auth = '1'"); } if($newlevel=="doublemetalaxe") { mysql_query("UPDATE game SET TotalGrade='13',SeasonGrade='13' WHERE auth = '1'"); } if($newlevel=="silveraxe") { mysql_query("UPDATE game SET TotalGrade='12',SeasonGrade='12' WHERE auth = '1'"); } if($newlevel=="doublesilveraxe") { mysql_query("UPDATE game SET TotalGrade='11',SeasonGrade='11' WHERE auth = '1'"); } if($newlevel=="goldaxe") { mysql_query("UPDATE game SET TotalGrade='10',SeasonGrade='10' WHERE auth = '1'"); } if($newlevel=="doublegoldaxe") { mysql_query("UPDATE game SET TotalGrade='9',SeasonGrade='9' WHERE auth = '1'"); } if($newlevel=="doublesmetalaxe") { mysql_query("UPDATE game SET TotalGrade='8',SeasonGrade='8' WHERE auth = '1'"); } if($newlevel=="doublesmetalaxeplus") { mysql_query("UPDATE game SET TotalGrade='7',SeasonGrade='7' WHERE auth = '1'"); } if($newlevel=="doublessilveraxe") { mysql_query("UPDATE game SET TotalGrade='6',SeasonGrade='6' WHERE auth = '1'"); } if($newlevel=="doublessilveraxeplus") { mysql_query("UPDATE game SET TotalGrade='5',SeasonGrade='5' WHERE auth = '1'"); } if($newlevel=="doublesgoldaxe") { mysql_query("UPDATE game SET TotalGrade='4',SeasonGrade='4' WHERE auth = '1'"); } if($newlevel=="doublesgoldaxeplus") { mysql_query("UPDATE game SET TotalGrade='3',SeasonGrade='3' WHERE auth = '1'"); } if($newlevel=="violethole") { mysql_query("UPDATE game SET TotalGrade='2',SeasonGrade='2' WHERE auth = '1'"); } if($newlevel=="sapphirehole") { mysql_query("UPDATE game SET TotalGrade='1',SeasonGrade='1' WHERE auth = '1'"); } if($newlevel=="redrubyhole") { mysql_query("UPDATE game SET TotalGrade='0',SeasonGrade='0' WHERE auth = '1'"); } if($newlevel=="diamondhole") { mysql_query("UPDATE game SET TotalGrade='-1',SeasonGrade='-1' WHERE auth = '1'"); } if($newlevel=="bluedragon") { mysql_query("UPDATE game SET TotalGrade='-2',SeasonGrade='-2' WHERE auth = '1'"); } if($newlevel=="reddragon") { mysql_query("UPDATE game SET TotalGrade='-3',SeasonGrade='-3' WHERE auth = '1'"); } if($newlevel=="silverdragon") { mysql_query("UPDATE game SET TotalGrade='-4',SeasonGrade='-4' WHERE auth = '1'"); } if($newlevel=="halloffame") { mysql_query("UPDATE game SET TotalGrade='-5',SeasonGrade='-5' WHERE auth = '1'"); } echo "Grades and levels of all members have been updated successfully!" ; ?> Help me, I don't know what to write in $gp= . This script is for updating the total grade and season grade as you can see, I want the $gp to be a result in which below script could use. $gp must get the value of TotalScore which is located in the table game. I hope anyone could help me. This is really urgent for my project =( ! Quote Link to comment https://forums.phpfreaks.com/topic/167561-help-in-update-script-urgent-sorry-for-other-wrong-post/ Share on other sites More sharing options...
vineld Posted July 27, 2009 Share Posted July 27, 2009 Just write some numbers above 1100 and see what happens. I don't really know what the point of it is though? :-\ You will not GET a total score but what the code does is that it updates the total score depending on the value of the $gp variable. That is some badly structured code btw. What's funny about it is that $newlevel can never be set to "doublesmetalaxeplus": if($gp>=14139) { $newlevel="doublesmetalaxeplus";} if($gp>=8438) { $newlevel="doublessilveraxe";} if($gp>=10482) { $newlevel="doublessilveraxeplus";} Quote Link to comment https://forums.phpfreaks.com/topic/167561-help-in-update-script-urgent-sorry-for-other-wrong-post/#findComment-883618 Share on other sites More sharing options...
RootDev Posted July 27, 2009 Author Share Posted July 27, 2009 $gp= must get the TotalScore value ( for all users ) . TotalScore is found in table game. help... Quote Link to comment https://forums.phpfreaks.com/topic/167561-help-in-update-script-urgent-sorry-for-other-wrong-post/#findComment-883619 Share on other sites More sharing options...
vineld Posted July 27, 2009 Share Posted July 27, 2009 Since I suspect this is for a school project or something like that you should try to find the solution yourself If it's not then you have some flaws in your code that needs to be corrected as well like the one I pointed out + you need to rethink the whole structure of it. Hint: write an sql statement that selects the (sum of I guess?) right column from the game table. Quote Link to comment https://forums.phpfreaks.com/topic/167561-help-in-update-script-urgent-sorry-for-other-wrong-post/#findComment-883621 Share on other sites More sharing options...
RootDev Posted July 27, 2009 Author Share Posted July 27, 2009 No!, Not the sum ! ah, and it's not for a school project =/ , I don't want the sum ! I just want to update the Grade of all users. that's what I meant. help help Quote Link to comment https://forums.phpfreaks.com/topic/167561-help-in-update-script-urgent-sorry-for-other-wrong-post/#findComment-883627 Share on other sites More sharing options...
abazoskib Posted July 27, 2009 Share Posted July 27, 2009 RootDev..you need to be more specific. Also, you ever hear of a switch Quote Link to comment https://forums.phpfreaks.com/topic/167561-help-in-update-script-urgent-sorry-for-other-wrong-post/#findComment-883662 Share on other sites More sharing options...
vineld Posted July 27, 2009 Share Posted July 27, 2009 A switch wouldn't be much better, the whole logic needs to be rethought. Quote Link to comment https://forums.phpfreaks.com/topic/167561-help-in-update-script-urgent-sorry-for-other-wrong-post/#findComment-883670 Share on other sites More sharing options...
RootDev Posted July 27, 2009 Author Share Posted July 27, 2009 guys, help me with this one. $result = mysql_query("SELECT gp FROM game"); while($row = mysql_fetch_array($result)) { $gp = $row['gp']; } and it worked, but worked so bad. It got the gp of the first user in the table and updated the grade of all the users according to the first user. Is there any other code to use to make it work for each user. thank you Quote Link to comment https://forums.phpfreaks.com/topic/167561-help-in-update-script-urgent-sorry-for-other-wrong-post/#findComment-883719 Share on other sites More sharing options...
abazoskib Posted July 27, 2009 Share Posted July 27, 2009 guys, help me with this one. $result = mysql_query("SELECT gp FROM game"); while($row = mysql_fetch_array($result)) { $gp = $row['gp']; } and it worked, but worked so bad. It got the gp of the first user in the table and updated the grade of all the users according to the first user. Is there any other code to use to make it work for each user. thank you you need to specify for whom you are getting the 'gp'. SELECT gp FROM game WHERE user_id=$user_id I don't know how your tables are set up so I cant give you a perfect answer. Quote Link to comment https://forums.phpfreaks.com/topic/167561-help-in-update-script-urgent-sorry-for-other-wrong-post/#findComment-883728 Share on other sites More sharing options...
RootDev Posted July 27, 2009 Author Share Posted July 27, 2009 Thanks for everyone here! I finally solved the problem. =D Quote Link to comment https://forums.phpfreaks.com/topic/167561-help-in-update-script-urgent-sorry-for-other-wrong-post/#findComment-883748 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.