bonjour
je voudrai construire un petit script de note de 1 à 20 exemple
un machin truc qui serrai noté dix huit sur vingt le dix huit proviendrai d'une base de donnée
le script récupére la note dans la base de donnée et construi une image avec une échelle gradué de 1 à 20 (un gif existant pour l'echelle )
et une barre rouge qui va jusqu'a dixhuit
j'ai ça en template qui ne marche pas
<?
//*****************************************
// Permet d'éviter les erreur PHP-NOTICE
if(!isset($infofilm22))
$infofilm22="";
if(!isset($_GET["note"]))
$note="";
else
$note=$_GET["note"];
//*****************************************
require_once("fonc.php");
header("Content-type: image/png");
if($infofilm22=="")$infofilm22="non-noté";
if($note=="")$note=$infofilm22;
// Dimension de l'image
$largeur = 320;
$hauteur = 28;
// Création de l'image
$img = imagecreate($largeur, $hauteur);
// Déclaration des couleurs utilisées
$fond = imageColorAllocate($img, 265, 265, 265);
$bleu = imageColorAllocate($img, 184, 212, 239);
$noir = imageColorAllocate($img, 0, 0, 0);
$barreCouleur = imageColorAllocate($img, 97, 118, 189);
// Taille des polices
$Police = 0;
$Police2 = 3;
// Met le fond de l'image transparent
imagecolortransparent($img,$fond);
// Tracé de l'échelle des notes
imageline ($img, 2, 14, 202, 14, $noir);
for($i=2,$nb=0;$i<=204;$i=$i+20,$nb=$nb+2)
{
imageline ($img, $i, 14, $i, 19, $noir);
if($i!=204)imageline ($img, $i+20, 14, $i+20, 16, $noir);
imageString($img,$Police,$i-2,21,$nb,$noir);
}
// Tracé de la barre représentant la note
$pattern = imagecreatefromPNG('./img/histo.png');
if($note!=$infofilm22)
{
// Test la version de la librairie GD
$testgd=CheckGDVersion();
if($testgd=="1")
imagecopyresized($img, $pattern, 2, 4, 0, 0, ($note*10)+2, 8, 1, 8);
elseif($testgd=="2")
imagecopyresampled($img, $pattern, 2, 4, 0, 0, ($note*10)+2, 8, 1, 8);
}
imageString($img,$Police2,220,6,"*".$note."*",$noir);
// Envoie de l'image au navigateur
imagePNG($img);
imageDestroy($img);
?>
et ça dans un autre fichier ça ne marche pas
if($note=="nn" ||$note=="")
$note=$infofilm30;
// Création du graphique pour la note
$testgd=CheckGDVersion();
if($testgd!="1" && $testgd!="2")
{
// Si la librairie GD n'est pas installé alors le graph est fait en HTML
$calnote0=$note*20;
$calnote1=100-($note*20);
// Création du graphique pour la note avec la librairie GD (1 ou 2, peut importe)
$aff_note=" <style type='text/css'>
.rateBackground
{
BACKGROUND-POSITION: left top;
BACKGROUND-IMAGE: url('img/histo.png');
BACKGROUND-REPEAT: repeat-x
}
</style>
<td height='10' width='$calnote0%' class='rateBackground'></td>
<td><a href=\'javascript:\" onclick='centerwindow(\"affimage.php?img=$stick_cd&taille1=$size[0]&taille2=$size[1]&titre=$titre2\",\"affichage\",$taille1,$taille2,true)'\'>
<img border='0' src='./img/legende2.gif' width='218' height='18'> * $note * </td> ";
}
else
{
$aff_note="<IMG src='./img_note.php?note=$note' border='0'> * $note * ";
}
$vtp->setVar($handle[1],"info_note_champ",$aff_note);