[gull] PHP et Mysql

Marc SCHAEFER schaefer at alphanet.ch
Mon Dec 1 21:11:01 CET 2003


On Mon, Dec 01, 2003 at 07:14:05PM +0100, Rafael Muñoz Moreno Davila wrote:
> while (mysql_fetch_array($result))
>     {
>       while ($row = @ mysql_fetch_row($result))
>       {
>          foreach($row as $data)
>          {
> 	   if ($data == "OUI")
> 	     $oui++;
> 	   if ($data == "NON")
> 	     $non++;
> 	
> 	   echo $data;	
> 	 }
>       }
>     }

Probablement que cela pourrait se faire avec un

SELECT COUNT(*) FROM ... WHERE data = 'OUI';
SELECT COUNT(*) FROM ... WHERE data = 'NON';

voire même avec un GROUP BY data en une seule requête. Beaucoup plus
efficace, moins de code PHP, moins de bugs.



More information about the gull mailing list