Valid XHTML    Valid CSS2    

Listing du fichier gcar.php

 

00001     <?php
00002     
00003     
# (gH) -_- gcar.php ; TimeStamp (unix) : 31 Mars 2013 vers 12:00
00004     
00005     
error_reporting(E_ALL | E_NOTICE | E_STRICT) ;
00006     include(
"std.php") ;
00007     
debutPage
("Google car","strict") ;
00008     
debutSection() ;
00009     
00010     
#############################################################################################
00011     
00012     
function
afficheHisto($jphurl,$altimg) {
00013     
00014     
p() ;
00015     
nbsp
(7) ;
00016      echo
href
($jphurl,img($jphurl,$altimg,"300")) ;
00017     
finp() ;
00018     
00019     }
# fin de fonction afficheHisto
00020     
00021     #############################################################################################
00022     
00023     
h2
("Histogramme du Google car") ;
00024     
00025     
# -------------------------------------------------------------------------------------------
00026     
00027     
h3
("Solution 1") ; # url directe
00028     
00029     
p() ;
00030     
nbsp
(7) ;
00031     
$url
= "../jphistopct.php?vdata=3_6_11_5&amp;xmrks=Lundi_Mardi_Jeudi_Vendredi&amp;titr=Google%20car" ;
00032     echo
href
($url,img($url,"google car","300")) ;
00033     
finp() ;
00034     
00035     
# -------------------------------------------------------------------------------------------
00036     
00037     
h3
("Solution 2") ; # deux tableaux
00038     
00039     
$km
= array("3","6","11","5") ;
00040     
$jr
= array("lundi","mardi","jeudi","vendredi") ;
00041     
00042     
$deburl
= "../jphistopct.php?" ;
00043     
$finurl
= "&amp;titr=Google%20car" ;
00044     
00045     
$midurl1
= "vdata=" ;
00046     
$midurl2
= "&amp;xmrks=" ;
00047     
$nbj
= count($jr) ;
00048     
00049     for (
$idj
=0;$idj<$nbj;$idj++) { # idj = indice de jour
00050     
$midurl1
.= $km[$idj] ;
00051     
$midurl2
.= $jr[$idj] ;
00052      if (
$idj
<$nbj-1) {
00053     
$midurl1
.= "_" ;
00054     
$midurl2
.= "_" ;
00055      } ;
# fin si
00056     
} ; # fin pour idj
00057     
00058     
$url
= $deburl . $midurl1 . $midurl2 . $finurl ;
00059     
00060     
afficheHisto
($url,"google car") ;
00061     
00062     
# -------------------------------------------------------------------------------------------
00063     
00064     
h3
("Solution 3") ; # deux chaines qui contiennent des mots
00065     
00066     
$km
= "3 6 11 5" ;
00067     
$jr
= "lundi mardi jeudi vendredi" ;
00068     
00069     
$deburl
= "../jphistopct.php?" ;
00070     
$finurl
= "&amp;titr=Google%20car" ;
00071     
00072     
$midurl1
= "vdata=" ;
00073     
$midurl2
= "&amp;xmrks=" ;
00074     
$nbm
= nbmots($jr) ;
00075     
00076     for (
$idm
=1;$idm<=$nbm;$idm++) { # idm = indice de mot
00077     
$midurl1
.= mot($km,$idm) ;
00078     
$midurl2
.= mot($jr,$idm) ;
00079      if (
$idm
<$nbm) {
00080     
$midurl1
.= "_" ;
00081     
$midurl2
.= "_" ;
00082      } ;
# fin si
00083     
} ; # fin pour idj
00084     
00085     
$url
= $deburl . $midurl1 . $midurl2 . $finurl ;
00086     
00087     
afficheHisto
($url,"google car") ;
00088     
00089     
# -------------------------------------------------------------------------------------------
00090     
00091     
h3
("Solution 4") ; # un tableau associatif
00092     
00093     
$data
= array("lundi"=>3,"mardi"=>6,"jeudi"=>11,"vendredi"=>5) ;
00094     
00095     
$deburl
= "../jphistopct.php?" ;
00096     
$finurl
= "&amp;titr=Google%20car" ;
00097     
00098     
$midurl1
= "vdata=" ;
00099     
$midurl2
= "&amp;xmrks=" ;
00100     
$nbm
= nbmots($jr) ;
00101     
00102     foreach (
$data
as $jr=>$km) {
00103     
$midurl1
.= $km."_" ;
00104     
$midurl2
.= $jr."_" ; # surtout pas "$jr_" ;
00105     
} ; # fin pour chaque
00106     
00107     # du coup, il y a un _ en trop à la fin
00108     
00109     
$midurl1
= substr($midurl1,0,strlen($midurl1)-1) ;
00110     
$midurl2
= substr($midurl2,0,strlen($midurl2)-1) ;
00111     
00112     
$url
= $deburl . $midurl1 . $midurl2 . $finurl ;
00113     
00114     
afficheHisto
($url,"google car") ;
00115     
00116     
#############################################################################################
00117     
00118     
finSection() ;
00119     
finPage() ;
00120     
?>

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)