Update
With this code I can retrieve the difference, but I can see only the first athlete of the query. Why? Shouldn't the while loop for x times, where x is the number of results?
function difference() {
global $db;
$result = $db->query("
SELECT *
FROM maxithlon
WHERE owner = '". $_SESSION[teamid] ."'
AND season = '". $this->season ."'
AND week = '". $this->currentWeek ."'
ORDER BY RAND();
");
while ($row = $result->fetch_assoc()) {
$result2 = $db->query("
SELECT *
FROM maxithlon
WHERE owner = '". $_SESSION[teamid] ."'
AND season = '". $this->season ."'
AND week = '". $this->currentWeek ."-1'
AND athleteId = '". $row[athleteId] ."'
");
while ($row2 = $result2->fetch_assoc()) {
$difference[$row2[athleteId]][form] = $row[form] - $row2[form];
$difference[$row2[athleteId]][maxid] = $row[maxid] - $row2[maxid];
$difference[experience] = $row[experience] - $row2[experience];
$difference[mood] = $row[mood] - $row2[mood];
$difference[strenght] = $row[strenght] - $row2[strenght];
$difference[stamina] = $row[stamina] - $row2[stamina];
$difference[speed] = $row[speed] - $row2[speed];
$difference[agility] = $row[agility] - $row2[agility];
$difference[jump] = $row[jump] - $row2[jump];
$difference[throws] = $row[throws] - $row2[throws];
$difference[specialty1] = $row[specialty1] - $row2[specialty1];
$difference[specialty2] = $row[specialty2] - $row2[specialty2];
$difference[height] = $row[height] - $row2[height];
$difference[weight] = $row[weight] - $row2[weight];
$difference[fans] = $row[fans] - $row2[fans];
$difference[wage] = $row[wage] - $row2[wage];
return($difference);
}
}
}
I've searched for an answer that could satisfy my needings, but I couldn't find it.
I have a database, with the "maxithlon" table that contains the athletes' data. The two functions are defined to retrieve the athletes' data and to put them in a array. The first retrieves the data of the last week, the second the data of the current one.
I need to compare the two arrays to obtain the difference between the values of the two weeks. Do you see a possible solution?
col1 > col2butcol3 == col4andcol5 != col6, what's the output?