if statement and imageline()
| From: | Hugh Danaher | Date: | Tue, 21 Aug 2001 06:16:16 +0000 |
| Subject: | if statement and imageline() | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-63631@lists.php.net to get a copy of this message | ||
help,
I am trying to set up a .jpg file to graph the earnings per year of a company. I can generate a
log-normal graph, can get it to display the earnings per year as circles on the graph, but I
can't get the " if () " statement to work. I know I am setting two of the variables
in the if statement after the if statement executes once, but these variables won't be used
until after the " for () " loops once, and therefore should be available for use in "
imageline() " on the second loop (where $year>$startyear). Somehow, I think my logic is
correct but it mustn't be so.
$startyear=1996;
$chart_start_year=1992;
for ($year=$startyear;$year<=$startyear+7;$year++)
{
$x=(($year-$chart_start_year)*20)+20;
$y=420-log(${"earnings_".$year})*75;
if ($year>$startyear)
{
imageline($image,$first_x,$first_y,$x,$y,$blue);
}
$first_x=$x;
$first_y=$y;
imagettftext($image,9,0,$x_distance-4,$y_distance+3,$blue,$font2,"m");
}