j'ai besoin d'aide sur un tri de tableau a partir de donnée recuperées sur sql.
La problematique est la suivante : j'aimerai trier le tableau de cette requete sur les valeur decroissante "$total" qui resulte de l'addition des valeur des donnée recuperées : $total=$ligne[1]+$ligne[0]; (qui vaut aussi $total=$score1+$score2;)
J'ai essayer avec ORDER BY total DESC mais ce ne marche pas...ce qui ne m'etonne pas car total n'est pas dans la table !!
Bref je cale... !!
Je vous joins le code et si vous y voyez des ameliorations je suis preneur (si possible avec les explications) car je suis debutant
Merciecho "<table width=450 align=\"center\" nowrap border=\"1\">";
echo "<tr><td width=120 align=\"center\"><font color=\"#CC9933\"><b>".Equipe."</td></b></font><td width=120 align=\"center\"><font color=\"#CC9933\"><b>".butdom."</td></b></font><td width=80 align=\"center\"><font color=\"#CC9933\"><b>".butext."</td></b></font><td width=80 align=\"center\"><font color=\"#CC9933\"><b>".buttotal."</td></b></font></tr>";
$result20 = $db->sql_query("select sum(score1)as butdom , sum(score2) as butext, tid1 from " . $prefix . "_league_schedule where score1 IS NOT NULL GROUP BY tid1 ");
while($ligne = $db->sql_fetchrow($result20)) {
$score1=$ligne[0];
$score2=$ligne[1];
$tid1=$ligne[2];
$total=$ligne[1]+$ligne[0];
$i= $i+1;
echo "<tr>
<td width=120 align=\"center\">". getTeamNamewithURL($tid1, "modules.php?name=League&file=index&op=team&tid=$tid1&sid=45&lid=1") ."</td>
<td width=120 align=\"center\">".$score1."</td>
<td width=120 align=\"center\">".$score2."</td>
<td width=120 align=\"center\">".$total."</td>
</tr>";
}
Jimmy