1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| <?php
include ('connexion_base.php');
// je recupere dans un tableau la table t_cim10_graphe
$query='SELECT X,Y FROM `coordonnees`';
$result=mysql_query($query) or die('La requête ne fonctionne pas.');
$nbr_enregistrement=mysql_num_rows($result);
//tableau $coord contient 2 colonnes: X et Y
while ($val=mysql_fetch_array($result))
{ $coord_x[]=$val[0];
$coord_y[]=$val[1];
}
mysql_close($maConnexion);
//********************************************
//********************************************/
//realisons le graphique
header ("Content-type: image/png");
//Taille image
$i_x=800;
$i_y=600;
$image=@imagecreate($i_x,$i_y);
//Couleurs utiles pour image
$couleur_fd=imagecolorallocate($image,0,185,92); //vert clair
$couleur_axe=imagecolorallocate($image,83,35,0); //marron
$couleur_texte=imagecolorallocate($image,70,70,70); //gris
$couleur_motif=imagecolorallocate($image,0,0,0); //noir
//affichage des pixels
for ($i=1;$i<$nbr_enregistrement;$i++)
{ $xg=$coord_x[$i];
$yg=$coord_y[$i];
imagesetpixel($image,$xg,$yg,$couleur_motif);
}
//affiche $image
imagepng($image);
?> |
Partager