| 12
 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
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 
 | <?php
header("Content-type: image/png");//on va commencer par declarer que l'on veut creer une image
 
//ensuite on defini la taille de l'image
$image_carte = imagecreate(303,303)   or die ("Cannot Initialize new GD image stream");
 
//maintenant on donne une couleur a notre image (ici un fond blanc)
$fond_carte=Imagecolorallocate($image_carte, 255, 255, 255);
 
require_once "../fonctions.php";
db_connexion();
 
// je vais chercher les terrains dans ma table
$sql = "SELECT x_carte, y_carte, fond_carte FROM carte";
$res = exec_requete($sql);
while ($t = mysql_fetch_assoc($res)){
   $x = $t["x_carte"];
   $y = $t["y_carte"];
   $fond_carte = explode(".",$t["fond_carte"]); // terrain de la forme "1.gif"
   $fond = $fond_carte[0]; // recuperation du num du terrain
 
      switch($fond){
         case "1" :
            $color = Imagecolorallocate($image_carte, 129, 156, 84);
            break;
         case "2" :
            $color = Imagecolorallocate($image_carte, 96, 110, 70);
            break;
         case "3" :
            $color = Imagecolorallocate($image_carte, 134, 118, 89);
            break;
         case "4" :
            $color = Imagecolorallocate($image_carte, 215, 197, 101);
            break;
         case "5" :
            $color = Imagecolorallocate($image_carte, 232, 248, 248);
            break;
         case "6" :
            $color = Imagecolorallocate($image_carte, 169, 177, 166);
            break;
         case "7" :
            $color = Imagecolorallocate($image_carte, 60, 86, 33);
            break;
         case "8" :
            $color = Imagecolorallocate($image_carte, 92, 191, 207);
            break;
         case "9" :
            $color = Imagecolorallocate($image_carte, 39, 141, 227);
            break;
      }
      imagefilledrectangle ($image_carte, (($x*3)-1), (((300-($y*3))-1)), (($x*3)+1), (((300-($y*3))+1)), $color);
}
// on affiche l'image
imagepng($image_carte, "carte.png");
ImageDestroy ($image_carte);
header("Location: afficher_carte.php");
?> | 
Partager