Valid XHTML    Valid CSS2    

Listing du fichier histos.php

 

00001     <?php
00002     
00003     
#####################################################
00004     
00005     
function histo($table,$champ,$modhom) {
00006     
00007     
#####################################################
00008     
00009     
h1
(" Tri à plat du code-sexe pour la table $table") ;
00010     
blockquote() ;
00011     
mysql_connect
("localhost","anonymous","anonymous") ;
00012     
mysql_select_db
("statdata") ;
00013     
$nbl
= nblEntout($table) ;
00014     
$qry
= " SELECT $champ, COUNT($champ) FROM $table GROUP BY $champ " ;
00015     
$res
= mysql_query($qry) ;
00016     
table
(1) ;
00017     
$vd
= "" ;
00018     
$xm
= "" ;
00019     
$nb
= 0 ;
00020      while (
$tdr
=mysql_fetch_array($res)) {
00021     
$nb++ ;
00022     
$nbe
= $tdr["COUNT($champ)"] ;
00023     
$pct
= sprintf("%5.1f %%",100*$nbe/$nbl) ;
00024     
$mod
= nomMod($tdr[$champ],$modhom) ;
00025     
ligne
( $mod, $nbe ,$pct ) ;
00026     
$vd
.= $nbe ;
00027     
$xm
.= $mod ; # au lieu de pct
00028     
if (
$nb<2) { $vd .= "_" ; $xm .= "_" ; } ;
00029      }
# fin tant que
00030     
fintable() ;
00031     
finblockquote() ;
00032     
center() ;
00033     
imagehisto
($vd,$xm,$table) ;
00034     
fincenter() ;
00035     
00036     }
# fin fonction histo
00037     
00038     #####################################################
00039     
00040     
function
nblEntout($table) {
00041     
00042     
#####################################################
00043     
00044     
$cha
= "COUNT(*)" ;
00045     
$qry
= "SELECT $cha FROM $table " ;
00046     
$res
= mysql_query($qry) ;
00047     
$tdr
= mysql_fetch_array($res) ;
00048      return(
$tdr
[$cha]) ;
00049     
00050     }
# fin fonction nblEntout
00051     
00052     #####################################################
00053     
00054     
function
ligne($a,$b,$c) {
00055     
00056     
#####################################################
00057     
00058     
tr() ;
00059     
td
("r") ; nbsp(3) ; echo $a ; nbsp(3) ; fintd() ;
00060     
td
("r") ; nbsp(3) ; echo $b ; nbsp(3) ; fintd() ;
00061     
td
("r") ; nbsp(3) ; echo $c ; nbsp(3) ; fintd() ;
00062     
fintr() ;
00063     
00064     }
# fin fonction ligne
00065     
00066     #####################################################
00067     
00068     
function
nomMod($codeHom,$modeHom) {
00069     
00070     
#####################################################
00071     
00072     
if(
$codeHom==$modeHom) {
00073      return(
"Hommes") ;
00074     } else {
00075      return(
"Femmes") ;
00076     } ;
# fin si
00077     
00078     
} # fin fonction nomMod
00079     
00080     #####################################################
00081     
00082     
function
imageHisto($a,$b,$c) {
00083     
00084     
#####################################################
00085     
00086     
$img
= "" ;
00087     
$img
.= "<img src=\"../jphistopct.php?vdata=$a&amp;xmrks=$b&amp;titr=$c&amp;tailx=400&amp;taily=300\" " ;
00088     
$img
.= " alt=\"histogramme\"" ;
00089     
$img
.= " />" ;
00090      echo
$img ;
00091     
# pour debug : echo "<xmp>echo $img</xmp>\n" ;
00092     
00093     
} # fin fonction imageHisto {
00094     
00095     #####################################################
00096     
00097     
?>

Pour ne pas voir les numéros de ligne, ajoutez &nl=non à la suite du nom du fichier.

 

 

retour gH    Retour à la page principale de   (gH)