par
Patriboom » 13 janv. 2008, 09:11
Ta requête ne servira-t-elle qu'à cette affichage ou en as-tu besoin autrement?
Si elle ne sert qu'à cela, tu peux faire un COUNT dans la partie SELECT et GROUP BY
par exemple:
$sql_country=mysql_query("SELECT code, country, COUNT(code) AS Combien FROM countries GROUP BY code");
$result_country=mysql_fetch_array($sql_country);
if($result_country[code]==""){
echo"<img src=\"flags/unknown.jpg\" border=\"1\"> ";
}else{
echo $result_country[Combien];
echo "<img src=\"flags/".$result_country[code].".jpg\" border=\"1\" alt=\"$result_country[country]\"> ";
MySQL fera tout le travail pour toi.
Ta requête ne servira-t-elle qu'à cette affichage ou en as-tu besoin autrement?
Si elle ne sert qu'à cela, tu peux faire un COUNT dans la partie SELECT et GROUP BY
par exemple:
[php]
$sql_country=mysql_query("SELECT code, country, COUNT(code) AS Combien FROM countries GROUP BY code");
$result_country=mysql_fetch_array($sql_country);
if($result_country[code]==""){
echo"<img src=\"flags/unknown.jpg\" border=\"1\"> ";
}else{
echo $result_country[Combien];
echo "<img src=\"flags/".$result_country[code].".jpg\" border=\"1\" alt=\"$result_country[country]\"> ";
[/php]
MySQL fera tout le travail pour toi.