Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Help in update script! urgent
Old 07-26-2009, 08:36 PM Help in update script! urgent
Junior Talker

Posts: 2
Trades: 0
PHP Code:
<?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 !

Last edited by rootdev; 07-26-2009 at 08:37 PM..
rootdev is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-26-2009, 10:52 PM Re: Help in update script! urgent
Average Talker

Posts: 19
Location: Canada
Trades: 0
So you just need to pick gp out of the table and update each entry based on the value of gp?

Why not use a:

PHP Code:
$result mysql_query("SELECT gp FROM game");

while(
$row mysql_fetch_array($result))
 {
   
$gp $row['gp'];

   
//rest of you're code.

Above code from http://www.php-mysql-tutorial.com/wi...-database.aspx.

However, there are many easier ways to do that. I'd put all the relevant information from each case into an array, then use a foreach, and if statement to determine which row of the array you need to access. I can explain more about this if you want.

Scott
scott_g is offline
Reply With Quote
View Public Profile
 
Old 07-27-2009, 12:36 AM Re: Help in update script! urgent
Junior Talker

Posts: 2
Trades: 0
Thanks Scott, but the problem is, It updates all users grade according to the first users' gp. =( , help please to fix this problem??
rootdev is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help in update script! urgent
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12267 seconds with 12 queries