Code: Select all
$link = mysql_connect("host", "user", "pass");
mysql_connect("host", "user", "pass") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$query = "SELECT * FROM lUsers"; //load all of the names of users to be tracked
$result = mysql_query($query) or die(mysql_error());
$i=0;
while($row = mysql_fetch_array($result)){ //loop through users
$perl[$i] = $row['lName']; //array containing names of the users
$i++;
}
mysql_close($link);
for ( $x = 0; $x < count($perl); $x++ ) { //loop through the users
$tUser = $perl[$x]; //temporary variable for the user
$page = sock( $tUser); //function that loads the stat data into a array
$skills = seed($page); //function that sorts all the data
for ( $i=0; $i<25; $i++ ) { //loop through skill columns
$e=0;
mysql_connect("host", "user", "pass") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$query1 = "SELECT * FROM $tUser ORDER BY $tUser.`Time` ASC"; //select the most all data entries for computation for the user and sorts by time
$result1 = mysql_query($query1) or die(mysql_error());
while($row1 = mysql_fetch_array($result1)){ //place data
$erl[$i][$e] = $row1[$names[$i]]; //places the data from each column in the users table into an array
$e++;
}
mysql_close($link);
}
for ( $i=0; $i<25; $i++ ) {
$peeve[$i] = explode(",",$erl[$i][count($erl[$i])-1]); //breaks the data string up into the actual components
$neeve[$i] = explode(",",$skills[$i]); //explodes the data string in the new stat array
$rank = $neeve[$i][0] - $peeve[$i][0]; //change in rank
$xp = $neeve[$i][2] - $peeve[$i][2]; //change in expereince
$xpp = round(($neeve[$i][2] - $peeve[$i][2]) / $peeve[0][2],5); //change in experience as % of total
$psas = round($neeve[$i][2] / $neeve[0][2],5); //% of skill as all skills
$sumt = $skills[$i].",".$rank.",".$xp.",".$xpp.",".$psas; //add all the data back into a data string
$skills[$i] = $sumt;
}
$time = time();
mysql_connect("host", "user", "pass") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
mysql_query("INSERT INTO $tUser
(Overall, Attack, Defence, Strength, Hitpoints, Ranged, Prayer, Magic, Cooking, Woodcutting, Fletching, Fishing, Firemaking, Crafting, Smithing, Mining, Herblore, Agility, Thieving, Slayer, Farming, Runecraft, Hunter, Construction, Summoning, Time) VALUES('$skills[0]','$skills[1]','$skills[2]','$skills[3]','$skills[4]','$skills[5]','$skills[6]','$skills[7]','$skills[8]','$skills[9]','$skills[10]','$skills[11]','$skills[12]','$skills[13]','$skills[14]','$skills[15]','$skills[16]','$skills[17]','$skills[18]','$skills[19]','$skills[20]','$skills[21]','$skills[22]','$skills[23]','$skills[24]','$time') ")
or die(mysql_error());
mysql_close($link);
}