Hallo,
ich versuche eine Ratingskala in PHP zu schreiben.
Code:
function drawRating($rating, $id) {
$link = mysql_connect('localhost', 'DB', 'password');
mysql_select_db('DB', $link);
$result = mysql_query("SELECT * FROM Accounts WHERE Username = '$user'");
$row = mysql_fetch_row($result);
$startvalue = $row(4); // For Exampel 105
$endvalue = $row(5); // For Exampel 82
$difference = $startvalue - $endvalue; // in exampel 23
$half = $difference / 2;
$image = imagecreate(102,40);
$maroon = ImageColorAllocate($image,123,9,60);
$white = ImageColorAllocate($image,255,255,255);
$black = ImageColorAllocate($image,0,0,0);
$red = ImageColorAllocate($image,255,60,75);
ImageFilledRectangle($image,0,0,101,19,$maroon);
ImageFilledRectangle($image,0,10,101,19,$white);
ImageFilledRectangle($image,1,11,$rating,18,$red);
ImageRectangle($image,0,10,101,19,$black);
ImageTTFText ($image, 8, 0, 1, 9, $white, "./arial.ttf","1");
ImageTTFText ($image, 8, 0, 48, 9, $white, "./arial.ttf",$half);
ImageTTFText ($image, 8, 0, 90, 9, $white, "./arial.ttf",$difference);
ImageTTFText ($image, 8, 0, 30, 33, $white, "./arial.ttf","Kg to go");
imagePNG($image);
imagedestroy($image);
}
Header("Content-type: image/png");
drawRating($rating,$id);
--> End of Code
Problem ist das er nicht so funktioniert wie ich mir das vorstelle.
Wenn ich die Werte der Variablen $half und $difference von Hand reinschreibe dann gehtb es.
ImageTTFText ($image, 8, 0, 90, 9, $white, "./arial.ttf","23");
Ansonsten Fehler:
<br />
<b>Fatal error</b>: Function name must be a string in <b>C:\Programme\xampplite\htdocs\wwclient\P01\rating.php</b> on line <b>28</b><br />
Kann mir hier einer helfen ?
Danke
ich versuche eine Ratingskala in PHP zu schreiben.
Code:
function drawRating($rating, $id) {
$link = mysql_connect('localhost', 'DB', 'password');
mysql_select_db('DB', $link);
$result = mysql_query("SELECT * FROM Accounts WHERE Username = '$user'");
$row = mysql_fetch_row($result);
$startvalue = $row(4); // For Exampel 105
$endvalue = $row(5); // For Exampel 82
$difference = $startvalue - $endvalue; // in exampel 23
$half = $difference / 2;
$image = imagecreate(102,40);
$maroon = ImageColorAllocate($image,123,9,60);
$white = ImageColorAllocate($image,255,255,255);
$black = ImageColorAllocate($image,0,0,0);
$red = ImageColorAllocate($image,255,60,75);
ImageFilledRectangle($image,0,0,101,19,$maroon);
ImageFilledRectangle($image,0,10,101,19,$white);
ImageFilledRectangle($image,1,11,$rating,18,$red);
ImageRectangle($image,0,10,101,19,$black);
ImageTTFText ($image, 8, 0, 1, 9, $white, "./arial.ttf","1");
ImageTTFText ($image, 8, 0, 48, 9, $white, "./arial.ttf",$half);
ImageTTFText ($image, 8, 0, 90, 9, $white, "./arial.ttf",$difference);
ImageTTFText ($image, 8, 0, 30, 33, $white, "./arial.ttf","Kg to go");
imagePNG($image);
imagedestroy($image);
}
Header("Content-type: image/png");
drawRating($rating,$id);
--> End of Code
Problem ist das er nicht so funktioniert wie ich mir das vorstelle.
Wenn ich die Werte der Variablen $half und $difference von Hand reinschreibe dann gehtb es.
ImageTTFText ($image, 8, 0, 90, 9, $white, "./arial.ttf","23");
Ansonsten Fehler:
<br />
<b>Fatal error</b>: Function name must be a string in <b>C:\Programme\xampplite\htdocs\wwclient\P01\rating.php</b> on line <b>28</b><br />
Kann mir hier einer helfen ?
Danke
Kommentar