Hallo, ik heb het volgende scriptje en wanneer ik deze draai had ik eerst een 'mooi' overzicht in blauw/wit maar nu zijn opeens de kleuren erg veranderd, waardoor dit komt is mij een raadsel maar kan helaas niet uitvinden waar het probleem zich inzit.
even een korte beschrijving van het script, lees antwoorden uit de database en maak daar statistieken van.. zoals voorbeeld onderstaand.
uitkomst:
JPEG formaat

PNG formaat

Wie o wie kan me helpen en ziet wat ik fout doe?
PHP:
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
| <? include("./include/config.include.php"); function make_seed() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 10000); } $font = "arial"; $fontsize = 11; $sql = "SELECT name, type_open FROM question_index WHERE id = " . $_GET['questionid']; $query = mysql_query($sql); $list = mysql_fetch_object($query); if ($list->type_open != true && isSet($_GET['questionid']) && is_numeric($_GET['questionid'])) { $title = $list->name; $sql = "SELECT id, question FROM question WHERE question_id=" . $_GET['questionid']; $query = mysql_query($sql) or die($sql); $answers = mysql_num_rows($query); for ($a = 0; $a < $answers; $a++) { $list = mysql_fetch_object($query); $sqlnew = "SELECT count(id) FROM answers WHERE answers.answer_id=" . $list->id; $querynew = mysql_query($sqlnew) or die($sqlnew); $listnew = mysql_result($querynew, 0); $graphline_text[$a] = $list->question . " (". $listnew . ")"; $graphline_votes[$a] = $listnew; $total += $listnew; if (strlen($graphline_text[$a]) > $graph_max_line_length) { $graph_max_line_length = strlen($graphline_text[$a]); } } // $answers = 10; $graph_start_line = $graph_max_line_length * 6.8; $graph_start_text = 5; $graph_height = 60 + ($answers * 20); $maxgraphheight = 220; $x = $maxgraphheight + 10 + $graph_start_line; if ($x - 350 > 0) { $graph_width = $x; } else { $graph_width = 350; } //neppe stats //---------- $statsimg = imagecreatetruecolor($graph_width, $graph_height); $row = imageColorAllocate($statsimg, 208, 208, 232); $text = imageColorAllocate($statsimg, 0, 0, 0); $balk = imageColorAllocate($statsimg, 94, 94, 174); $balkdark = imageColorAllocate($statsimg, 60, 60, 119); $white = imageColorAllocate($statsimg, 255, 255, 255); // --- bereken van maximale lengte $tot = @array_sum($graphline_votes); $max = $graphline_votes; @rsort($max); @reset($max); $max = $max[0]; @reset($graphline_votes); imagettftext ($statsimg, 20, 0, 5, 25, -$text, $font, $title); if ($answers > 0) { imagettftext ($statsimg, 10, 0, 5, $graph_height - 6, -$text, $font, "total answers: " . $answers); } else { imagettftext ($statsimg, 10, 0, 5, $graph_height - 6, -$text, $font, "sorry, no anwsers found..."); } for ($a = 0; $a < $answers; $a++) { $thepercentage = ($graphline_votes[$a]/$max)*100; $x = floor($maxgraphheight * ($thepercentage/100)); imagefilledrectangle ($statsimg, $graph_start_line, 40 + ($a * 20), $graph_start_line + $x , 55 + ($a * 20), $balk); imagettftext ($statsimg, 10, 0, $graph_start_text, 49 + ($a * 20), $white, $font, $graphline_text[$a]); } } else { $graph_height = 80; $graph_width = 220; //neppe stats //---------- $statsimg = imagecreatetruecolor($graph_width, $graph_height); $row = imageColorAllocate($statsimg, 208, 208, 232); $text = imageColorAllocate($statsimg, 0, 0, 0); $balk = imageColorAllocate($statsimg, 94, 94, 174); $balkdark = imageColorAllocate($statsimg, 60, 60, 119); $white = imageColorAllocate($statsimg, 255, 255, 255); imagettftext ($statsimg, 20, 0, 5, 25, -$text, $font, "Error!"); imagettftext ($statsimg, 9, 0, 5, $graph_height - 26, $text, $font, "You are requesting data from an open"); imagettftext ($statsimg, 9, 0, 5, $graph_height - 6, $text, $font, "question, wich we cannot process"); } Header("Content-type: image/png"); ImagePng($statsimg); ImageDestroy($statsimg); ?> |
even een korte beschrijving van het script, lees antwoorden uit de database en maak daar statistieken van.. zoals voorbeeld onderstaand.
uitkomst:
JPEG formaat

PNG formaat

Wie o wie kan me helpen en ziet wat ik fout doe?