I have the code as show below to collect variables from a mysql-database as well as create some variables in php using database collected variables to calculate from. I want to order the table 1) $point 2) $diff 3) $plus. Can I do this directly in PHP? If yes, how? If not, can I create columns in the mysql-database that automaticly updates when a relating column is being updated? (ie if I increase the column named won with 1 the (new) column tot_points is set to ((win3)+(draw1)). Is it possible to use a recursive function fix this problem in PHP? (If yes, what would that function look like?)
$query = "SELECT * FROM $table1 WHERE league='$league'";
$result=mysql_query($query);
$num=mysql_numrows($result);
echo "<table border=0><tr><td width=150>Lag</td><td width=20>S</td><td width=20>V</td><td width=20>O</td><td width=20>F</td><td width=20 align=center>+</td><td width=20 align=center>-</td><td width=20 align=center>+/-</td><td width=20 align=center>P</td></tr>";
for ($counter=0;$counter<$num;$counter++)
{
$team[$counter+1]=mysql_result($result,$counter,'team');
$won[$counter+1]=mysql_result($result,$counter,'won');
$draw[$counter+1]=mysql_result($result,$counter,'draw');
$lost[$counter+1]=mysql_result($result,$counter,'lost');
$played[$counter+1]=$won[$counter+1]+$draw[$counter+1]+$lost[$counter+1];
$plus[$counter+1]=mysql_result($result,$counter,'plus');
$minus[$counter+1]=mysql_result($result,$counter,'minus');
$diff[$counter+1]=$plus[$counter+1]-$minus[$counter+1];
$point[$counter+1]=$won[$counter+1]*3+$draw[$counter+1]*1;
echo "<tr><td>",$team[$counter+1],"</td><td>",$played[$counter+1],"</td><td>",$won[$counter+1],"</td><td>",$draw[$counter+1],"</td><td>",$lost[$counter+1],"</td><td align=right>",$plus[$counter+1],"</td><td align=right>",$minus[$counter+1],"</td><td align=right>",$diff[$counter+1],"</td><td align=right>",$point[$counter+1],"</td></tr>";
}
echo "</table>";