Jump to content

Help in update script! urgent (Sorry for other wrong post)


RootDev

Recommended Posts

<?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 =( !

Link to comment
Share on other sites

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";}

 

:P

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.