[GDLib] Afbeelding bevat fouten		
			
		
		 		
				
		
                        
                 
            
            
				
                
                    Frederic (laatste wijziging 06/04/2005 14:05)                       
             
             
                        
                PHP ver gevorderde 
				
				Ik wil graag een grafiekje maken, met onderstaand script:
    
    
        
            
                <? $hoofdarray = array(
"1-1" => 45,
"2-1" => 35,
"3-1" => 42,
"4-1" => 46,
"5-1" => 51,
"6-1" => 49,
"7-1" => 33,
"8-1" => 39,
"9-1" => 40,
"10-1" => 34
); ?>
 
             
            "1-1"  =>  45 , 
"2-1"  =>  35 , 
"3-1"  =>  42 , 
"4-1"  =>  46 , 
"5-1"  =>  51 , 
"6-1"  =>  49 , 
"7-1"  =>  33 , 
"8-1"  =>  39 , 
"9-1"  =>  40 , 
"10-1"  =>  34 
) ;  ?> 
 
         
     
  
    
    
        
            
                <? $hoofdarray = array(
$sql = mysql_query("SELECT * FROM site_database_grootte");            
while($rij = mysql_fetch_assoc($sql))
{ 
$datum = $rij['datum'];
$grootte = $rij['grootte'];
$datum => $grootte
}
);?>
 
             
            $sql  =  mysql_query ( "SELECT * FROM site_database_grootte" ) ;             {  
$datum  =  $rij [ 'datum' ] ; 
$grootte  =  $rij [ 'grootte' ] ; 
 
$datum  =>  $grootte 
} 
) ; ?> 
 
         
     
 
    
    
        
            
                
     id    datum            grootte (INT)
     1     2005-04-05     2000
     2     2005-04-05     2057
     3     2005-04-05     2057 
             
            id    datum            grootte ( INT) 
     1      2005 - 04 - 05      2000 
     2      2005 - 04 - 05      2057 
     3      2005 - 04 - 05      2057 
 
         
     
  
    
    
        
            
                <?php
$titel = "Grootte MySQL";
// array op deze manier genereren $hoofdarray = array(x-as => y-as)
// bv:
$sql = MySQL_query("SELECT * FROM site_database_grootte");            
while( $rij = mysql_fetch_assoc( $sql ) ) { 
   $datum = $rij['datum'];
   $grootte = $rij['grootte'];
   $hoofdarray = array($datum => $grootte);
}
$gebied_breedte = 400; // grootte van de grafiek zelf (zonder randen)
$gebied_hoogte = 200; // hoogte van de grafiek zelf (zonder randen)
$rand_links = 20; // de breedte van de linker rand (hou rekening met de lengte van de waardes die op de y-as komen, in toekomst misschien automatisch)
$rand_rechts = 10; // de breedte van de rechter rand
$rand_onder = 40; // de rand onder de grafiek (hou rekening met de lengte van de waardes die op de x-as komen, in toekomst misschien automatisch)
$rand_boven = 30; // de rand boven (hou rekening met de titel die hier in komt)
$hor_lijnen = 4; // het aantal verdelingen van de y-as
$hor_raster = TRUE; // horizontale lijnen zichtbaar?
$ver_lijnen = 10; // het aantal verdelingen van de x-as
$ver_raster = FALSE; // verticale lijnen zichtbaar?
$grafiek_titel = $titel; // de titel van de grafiek
header("Content-type: image/png");
if(function_exists("ImageCreateTrueColor"))
{
    $plaatje = ImageCreateTrueColor(($gebied_breedte + $rand_rechts + $rand_links), ($gebied_hoogte + $rand_onder + $rand_boven));
}
else
{
    $plaatje = ImageCreate(($gebied_breedte + $rand_rechts + $rand_links), ($gebied_hoogte + $rand_onder + $rand_boven));
}
$zwart = ImageColorAllocate($plaatje, 000, 000, 000);
$wit = ImageColorAllocate($plaatje, 255, 255, 255);
$grijs = ImageColorAllocate($plaatje, 225, 225, 225);
$lijn = ImageColorAllocate($plaatje, 000, 000, 255); // blauwe grafieklijn
imagefill($plaatje,1,1,$wit);
// zwarte rand of niet:
//imagefilledrectangle($plaatje, 1, 1, ($gebied_breedte + $rand_rechts + $rand_links - 2), ($gebied_hoogte + $rand_onder + $rand_boven -2), $wit); //
imagefilledrectangle($plaatje, ($rand_links + 1), ($rand_boven + 1), ($rand_links + $gebied_breedte - 1), ($rand_boven + $gebied_hoogte -1), $grijs);
$hoogste = 1;
foreach($hoofdarray as $key => $value)if($value > $hoogste)$hoogste = $value;
$style=array($zwart, $zwart, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT );
imagesetstyle($plaatje,$style);
$waarde = 1;
for($y = $rand_boven;$y < ($gebied_hoogte + $rand_boven + 1);$y += ($gebied_hoogte / $hor_lijnen))
{
    $align = $rand_links - 3 - strlen(round($hoogste * $waarde)) * 5;
    imagestring($plaatje, 2, $align, $y - 7 , round($hoogste * $waarde), $zwart);
    if($hor_raster)imageline($plaatje, $rand_links, $y, ($rand_links + $gebied_breedte), $y, IMG_COLOR_STYLED);
    $waarde -= (1 / $hor_lijnen);
}
$aantal = count($hoofdarray);
$interval = $gebied_breedte / ($aantal - 1);
$yinterval = $gebied_hoogte / $hoogste;
$x = $rand_links;
$coords = array();
$ticker = 0;
$numdates = round($aantal / $ver_lijnen);
if($numdates < 1)$numdates = 1;
foreach($hoofdarray as $xas => $yas)
{
    $coords[$ticker]["x"] = round($x);
    $coords[$ticker]["y"] = ($rand_boven + $gebied_hoogte) - (round($yas * $yinterval));
    
    if($ticker / $numdates == round($ticker / $numdates) || $ticker == 0 || $ticker == $aantal-1)
    {
        $align = ($gebied_hoogte + $rand_boven) + (strlen($xas) * 5) + 5;
        imagestringup($plaatje, 2 , round($x) - 7 , $align,  $xas ,$zwart);
        if($ver_raster)imageline($plaatje, round($x) , $rand_boven , round($x) , ($rand_boven + $gebied_hoogte), IMG_COLOR_STYLED);
    }
    
    $x += $interval;
    $ticker++;
} 
for($a = 0;$a < count($coords)-1;$a++)
{
    imagesmoothline($plaatje, $coords[$a]["x"] , $coords[$a]["y"] , $coords[$a+1]["x"] , $coords[$a+1]["y"], $lijn);
}
imagerectangle($plaatje, $rand_links, $rand_boven, ($rand_links + $gebied_breedte), ($rand_boven + $gebied_hoogte), $zwart); 
imagestring($plaatje, 4 , ((($rand_links + $rand_rechts + $gebied_breedte) / 2) - ((strlen($grafiek_titel) / 2) * 8)) , ($rand_boven / 2) - 8 , $grafiek_titel , $zwart);
    
ImagePNG($plaatje);
ImageDestroy($plaatje);
// functie voor de anti-aliasing van de grafieklijn (van php.net)
function imagesmoothline ( $image , $x1 , $y1 , $x2 , $y2 , $color )
 {
  $colors = imagecolorsforindex ( $image , $color );
  if ( $x1 == $x2 )
  {
   imageline ( $image , $x1 , $y1 , $x2 , $y2 , $color ); // Vertical line
  }
  else
  {
   $m = ( $y2 - $y1 ) / ( $x2 - $x1 );
   $b = $y1 - $m * $x1;
   if ( abs ( $m ) <= 1 )
   {
   $x = min ( $x1 , $x2 );
   $endx = max ( $x1 , $x2 );
   while ( $x <= $endx )
   {
     $y = $m * $x + $b;
     $y == floor ( $y ) ? $ya = 1 : $ya = $y - floor ( $y );
     $yb = ceil ( $y ) - $y;
     $tempcolors = imagecolorsforindex ( $image , imagecolorat ( $image , $x , floor ( $y ) ) );
     $tempcolors['red'] = $tempcolors['red'] * $ya + $colors['red'] * $yb;
     $tempcolors['green'] = $tempcolors['green'] * $ya + $colors['green'] * $yb;
     $tempcolors['blue'] = $tempcolors['blue'] * $ya + $colors['blue'] * $yb;
     if ( imagecolorexact ( $image , $tempcolors['red'] , $tempcolors['green'] , $tempcolors['blue'] ) == -1 ) imagecolorallocate ( $image , $tempcolors['red'] , $tempcolors['green'] , $tempcolors['blue'] );
     imagesetpixel ( $image , $x , floor ( $y ) , imagecolorexact ( $image , $tempcolors['red'] , $tempcolors['green'] , $tempcolors['blue'] ) );
     $tempcolors = imagecolorsforindex ( $image , imagecolorat ( $image , $x , ceil ( $y ) ) );
     $tempcolors['red'] = $tempcolors['red'] * $yb + $colors['red'] * $ya;
     $tempcolors['green'] = $tempcolors['green'] * $yb + $colors['green'] * $ya;
     $tempcolors['blue'] = $tempcolors['blue'] * $yb + $colors['blue'] * $ya;
     if ( imagecolorexact ( $image , $tempcolors['red'] , $tempcolors['green'] , $tempcolors['blue'] ) == -1 ) imagecolorallocate ( $image , $tempcolors['red'] , $tempcolors['green'] , $tempcolors['blue'] );
     imagesetpixel ( $image , $x , ceil ( $y ) , imagecolorexact ( $image , $tempcolors['red'] , $tempcolors['green'] , $tempcolors['blue'] ) );
     $x ++;
   }
   }
   else
   {
   $y = min ( $y1 , $y2 );
   $endy = max ( $y1 , $y2 );
   while ( $y <= $endy )
   {
     $x = ( $y - $b ) / $m;
     $x == floor ( $x ) ? $xa = 1 : $xa = $x - floor ( $x );
     $xb = ceil ( $x ) - $x;
     $tempcolors = imagecolorsforindex ( $image , imagecolorat ( $image , floor ( $x ) , $y ) );
     $tempcolors['red'] = $tempcolors['red'] * $xa + $colors['red'] * $xb;
     $tempcolors['green'] = $tempcolors['green'] * $xa + $colors['green'] * $xb;
     $tempcolors['blue'] = $tempcolors['blue'] * $xa + $colors['blue'] * $xb;
     if ( imagecolorexact ( $image , $tempcolors['red'] , $tempcolors['green'] , $tempcolors['blue'] ) == -1 ) imagecolorallocate ( $image , $tempcolors['red'] , $tempcolors['green'] , $tempcolors['blue'] );
     imagesetpixel ( $image , floor ( $x ) , $y , imagecolorexact ( $image , $tempcolors['red'] , $tempcolors['green'] , $tempcolors['blue'] ) );
     $tempcolors = imagecolorsforindex ( $image , imagecolorat ( $image , ceil ( $x ) , $y ) );
     $tempcolors['red'] = $tempcolors['red'] * $xb + $colors['red'] * $xa;
     $tempcolors['green'] = $tempcolors['green'] * $xb + $colors['green'] * $xa;
     $tempcolors['blue'] = $tempcolors['blue'] * $xb + $colors['blue'] * $xa;
     if ( imagecolorexact ( $image , $tempcolors['red'] , $tempcolors['green'] , $tempcolors['blue'] ) == -1 ) imagecolorallocate ( $image , $tempcolors['red'] , $tempcolors['green'] , $tempcolors['blue'] );
     imagesetpixel ( $image , ceil ( $x ) , $y , imagecolorexact ( $image , $tempcolors['red'] , $tempcolors['green'] , $tempcolors['blue'] ) );
     $y ++;
   }
   }
  }
 }
?> 
             
            <?php 
$titel  =  "Grootte MySQL" ; 
 
// array op deze manier genereren $hoofdarray = array(x-as => y-as) 
// bv: 
$sql  =  MySQL_query ( "SELECT * FROM site_database_grootte" ) ;                $datum  =  $rij [ 'datum' ] ; 
   $grootte  =  $rij [ 'grootte' ] ; 
   $hoofdarray  =  array ( $datum  =>  $grootte ) ;  } 
$gebied_breedte  =  400 ;  // grootte van de grafiek zelf (zonder randen) 
$gebied_hoogte  =  200 ;  // hoogte van de grafiek zelf (zonder randen) 
$rand_links  =  20 ;  // de breedte van de linker rand (hou rekening met de lengte van de waardes die op de y-as komen, in toekomst misschien automatisch) 
$rand_rechts  =  10 ;  // de breedte van de rechter rand 
$rand_onder  =  40 ;  // de rand onder de grafiek (hou rekening met de lengte van de waardes die op de x-as komen, in toekomst misschien automatisch) 
$rand_boven  =  30 ;  // de rand boven (hou rekening met de titel die hier in komt) 
$hor_lijnen  =  4 ;  // het aantal verdelingen van de y-as 
$hor_raster  =  TRUE ;  // horizontale lijnen zichtbaar? 
$ver_lijnen  =  10 ;  // het aantal verdelingen van de x-as 
$ver_raster  =  FALSE ;  // verticale lijnen zichtbaar? 
$grafiek_titel  =  $titel ;  // de titel van de grafiek 
 
header ( "Content-type: image/png" ) ;  
{ 
    $plaatje  =  ImageCreateTrueColor( ( $gebied_breedte  +  $rand_rechts  +  $rand_links ) ,  ( $gebied_hoogte  +  $rand_onder  +  $rand_boven ) ) ; 
} 
else 
{ 
    $plaatje  =  ImageCreate( ( $gebied_breedte  +  $rand_rechts  +  $rand_links ) ,  ( $gebied_hoogte  +  $rand_onder  +  $rand_boven ) ) ; 
} 
 
$zwart  =  ImageColorAllocate( $plaatje ,  000 ,  000 ,  000 ) ; 
$wit  =  ImageColorAllocate( $plaatje ,  255 ,  255 ,  255 ) ; 
$grijs  =  ImageColorAllocate( $plaatje ,  225 ,  225 ,  225 ) ; 
$lijn  =  ImageColorAllocate( $plaatje ,  000 ,  000 ,  255 ) ;  // blauwe grafieklijn 
 
imagefill( $plaatje , 1 , 1 , $wit ) ; 
// zwarte rand of niet: 
//imagefilledrectangle($plaatje, 1, 1, ($gebied_breedte + $rand_rechts + $rand_links - 2), ($gebied_hoogte + $rand_onder + $rand_boven -2), $wit); // 
 
 
imagefilledrectangle( $plaatje ,  ( $rand_links  +  1 ) ,  ( $rand_boven  +  1 ) ,  ( $rand_links  +  $gebied_breedte  -  1 ) ,  ( $rand_boven  +  $gebied_hoogte  - 1 ) ,  $grijs ) ; 
 
$hoogste  =  1 ; 
foreach ( $hoofdarray  as  $key  =>  $value ) if ( $value  >  $hoogste ) $hoogste  =  $value ; 
 
$style = array ( $zwart ,  $zwart ,  IMG_COLOR_TRANSPARENT
,  IMG_COLOR_TRANSPARENT
,  IMG_COLOR_TRANSPARENT 
) ; imagesetstyle( $plaatje , $style ) ; 
 
$waarde  =  1 ; 
for ( $y  =  $rand_boven ; $y  <  ( $gebied_hoogte  +  $rand_boven  +  1 ) ; $y  +=  ( $gebied_hoogte  /  $hor_lijnen ) ) 
{ 
    $align  =  $rand_links  -  3  -  strlen ( round ( $hoogste  *  $waarde ) )  *  5 ;      imagestring
( $plaatje ,  2 ,  $align ,  $y  -  7  ,  round ( $hoogste  *  $waarde ) ,  $zwart ) ;     if ( $hor_raster ) imageline( $plaatje ,  $rand_links ,  $y ,  ( $rand_links  +  $gebied_breedte ) ,  $y ,  IMG_COLOR_STYLED) ; 
    $waarde  -=  ( 1  /  $hor_lijnen ) ; 
} 
$aantal  =  count ( $hoofdarray ) ; $interval  =  $gebied_breedte  /  ( $aantal  -  1 ) ; 
$yinterval  =  $gebied_hoogte  /  $hoogste ; 
$x  =  $rand_links ; 
$ticker  =  0 ; 
$numdates  =  round ( $aantal  /  $ver_lijnen ) ; if ( $numdates  <  1 ) $numdates  =  1 ; 
foreach ( $hoofdarray  as  $xas  =>  $yas ) 
{ 
 
    $coords [ $ticker ] [ "x" ]  =  round ( $x ) ;      $coords [ $ticker ] [ "y" ]  =  ( $rand_boven  +  $gebied_hoogte )  -  ( round ( $yas  *  $yinterval ) ) ;   
    if ( $ticker  /  $numdates  ==  round ( $ticker  /  $numdates )  ||  $ticker  ==  0  ||  $ticker  ==  $aantal - 1 )      { 
        $align  =  ( $gebied_hoogte  +  $rand_boven )  +  ( strlen ( $xas )  *  5 )  +  5 ;          imagestringup
( $plaatje ,  2  ,  round ( $x )  -  7  ,  $align ,   $xas  , $zwart ) ;         if ( $ver_raster ) imageline
( $plaatje ,  round ( $x )  ,  $rand_boven  ,  round ( $x )  ,  ( $rand_boven  +  $gebied_hoogte ) ,  IMG_COLOR_STYLED
) ;      } 
 
    $x  +=  $interval ; 
    $ticker ++; 
}  
for ( $a  =  0 ; $a  <  count ( $coords ) - 1 ; $a ++ ) { 
    imagesmoothline( $plaatje ,  $coords [ $a ] [ "x" ]  ,  $coords [ $a ] [ "y" ]  ,  $coords [ $a + 1 ] [ "x" ]  ,  $coords [ $a + 1 ] [ "y" ] ,  $lijn ) ; 
} 
 
imagerectangle( $plaatje ,  $rand_links ,  $rand_boven ,  ( $rand_links  +  $gebied_breedte ) ,  ( $rand_boven  +  $gebied_hoogte ) ,  $zwart ) ;  
 
imagestring
( $plaatje ,  4  ,  ( ( ( $rand_links  +  $rand_rechts  +  $gebied_breedte )  /  2 )  -  ( ( strlen ( $grafiek_titel )  /  2 )  *  8 ) )  ,  ( $rand_boven  /  2 )  -  8  ,  $grafiek_titel  ,  $zwart ) ;  
ImagePNG( $plaatje ) ; 
ImageDestroy( $plaatje ) ; 
 
 
 
// functie voor de anti-aliasing van de grafieklijn (van php.net) 
function  imagesmoothline (  $image  ,  $x1  ,  $y1  ,  $x2  ,  $y2  ,  $color  ) 
 { 
  $colors  =  imagecolorsforindex (  $image  ,  $color  ) ; 
  if  (  $x1  ==  $x2  ) 
  { 
   imageline (  $image  ,  $x1  ,  $y1  ,  $x2  ,  $y2  ,  $color  ) ;  // Vertical line 
  } 
  else 
  { 
   $m  =  (  $y2  -  $y1  )  /  (  $x2  -  $x1  ) ; 
   $b  =  $y1  -  $m  *  $x1 ; 
   { 
   $endx  =  max (  $x1  ,  $x2  ) ;     while  (  $x  <=  $endx  ) 
   { 
     $y  =  $m  *  $x  +  $b ; 
     $y  ==  floor (  $y  )  ? 
$ya  =  1  :  $ya  =  $y  -  floor (  $y  ) ;       $tempcolors  =  imagecolorsforindex 
(  $image  ,  imagecolorat 
(  $image  ,  $x  ,  floor (  $y  )  )  ) ;       $tempcolors [ 'red' ]  =  $tempcolors [ 'red' ]  *  $ya  +  $colors [ 'red' ]  *  $yb ; 
     $tempcolors [ 'green' ]  =  $tempcolors [ 'green' ]  *  $ya  +  $colors [ 'green' ]  *  $yb ; 
     $tempcolors [ 'blue' ]  =  $tempcolors [ 'blue' ]  *  $ya  +  $colors [ 'blue' ]  *  $yb ; 
     if  (  imagecolorexact (  $image  ,  $tempcolors [ 'red' ]  ,  $tempcolors [ 'green' ]  ,  $tempcolors [ 'blue' ]  )  ==  - 1  )  imagecolorallocate (  $image  ,  $tempcolors [ 'red' ]  ,  $tempcolors [ 'green' ]  ,  $tempcolors [ 'blue' ]  ) ; 
     imagesetpixel 
(  $image  ,  $x  ,  floor (  $y  )  ,  imagecolorexact 
(  $image  ,  $tempcolors [ 'red' ]  ,  $tempcolors [ 'green' ]  ,  $tempcolors [ 'blue' ]  )  ) ;      $tempcolors  =  imagecolorsforindex 
(  $image  ,  imagecolorat 
(  $image  ,  $x  ,  ceil (  $y  )  )  ) ;       $tempcolors [ 'red' ]  =  $tempcolors [ 'red' ]  *  $yb  +  $colors [ 'red' ]  *  $ya ; 
     $tempcolors [ 'green' ]  =  $tempcolors [ 'green' ]  *  $yb  +  $colors [ 'green' ]  *  $ya ; 
     $tempcolors [ 'blue' ]  =  $tempcolors [ 'blue' ]  *  $yb  +  $colors [ 'blue' ]  *  $ya ; 
     if  (  imagecolorexact (  $image  ,  $tempcolors [ 'red' ]  ,  $tempcolors [ 'green' ]  ,  $tempcolors [ 'blue' ]  )  ==  - 1  )  imagecolorallocate (  $image  ,  $tempcolors [ 'red' ]  ,  $tempcolors [ 'green' ]  ,  $tempcolors [ 'blue' ]  ) ; 
     imagesetpixel 
(  $image  ,  $x  ,  ceil (  $y  )  ,  imagecolorexact 
(  $image  ,  $tempcolors [ 'red' ]  ,  $tempcolors [ 'green' ]  ,  $tempcolors [ 'blue' ]  )  ) ;      $x  ++; 
   } 
   } 
   else 
   { 
   $endy  =  max (  $y1  ,  $y2  ) ;     while  (  $y  <=  $endy  ) 
   { 
     $x  =  (  $y  -  $b  )  /  $m ; 
     $x  ==  floor (  $x  )  ? 
$xa  =  1  :  $xa  =  $x  -  floor (  $x  ) ;       $tempcolors  =  imagecolorsforindex 
(  $image  ,  imagecolorat 
(  $image  ,  floor (  $x  )  ,  $y  )  ) ;       $tempcolors [ 'red' ]  =  $tempcolors [ 'red' ]  *  $xa  +  $colors [ 'red' ]  *  $xb ; 
     $tempcolors [ 'green' ]  =  $tempcolors [ 'green' ]  *  $xa  +  $colors [ 'green' ]  *  $xb ; 
     $tempcolors [ 'blue' ]  =  $tempcolors [ 'blue' ]  *  $xa  +  $colors [ 'blue' ]  *  $xb ; 
     if  (  imagecolorexact (  $image  ,  $tempcolors [ 'red' ]  ,  $tempcolors [ 'green' ]  ,  $tempcolors [ 'blue' ]  )  ==  - 1  )  imagecolorallocate (  $image  ,  $tempcolors [ 'red' ]  ,  $tempcolors [ 'green' ]  ,  $tempcolors [ 'blue' ]  ) ; 
     imagesetpixel 
(  $image  ,  floor (  $x  )  ,  $y  ,  imagecolorexact 
(  $image  ,  $tempcolors [ 'red' ]  ,  $tempcolors [ 'green' ]  ,  $tempcolors [ 'blue' ]  )  ) ;      $tempcolors  =  imagecolorsforindex 
(  $image  ,  imagecolorat 
(  $image  ,  ceil (  $x  )  ,  $y  )  ) ;       $tempcolors [ 'red' ]  =  $tempcolors [ 'red' ]  *  $xb  +  $colors [ 'red' ]  *  $xa ; 
     $tempcolors [ 'green' ]  =  $tempcolors [ 'green' ]  *  $xb  +  $colors [ 'green' ]  *  $xa ; 
     $tempcolors [ 'blue' ]  =  $tempcolors [ 'blue' ]  *  $xb  +  $colors [ 'blue' ]  *  $xa ; 
     if  (  imagecolorexact (  $image  ,  $tempcolors [ 'red' ]  ,  $tempcolors [ 'green' ]  ,  $tempcolors [ 'blue' ]  )  ==  - 1  )  imagecolorallocate (  $image  ,  $tempcolors [ 'red' ]  ,  $tempcolors [ 'green' ]  ,  $tempcolors [ 'blue' ]  ) ; 
     imagesetpixel 
(  $image  ,  ceil (  $x  )  ,  $y  ,  imagecolorexact 
(  $image  ,  $tempcolors [ 'red' ]  ,  $tempcolors [ 'green' ]  ,  $tempcolors [ 'blue' ]  )  ) ;      $y  ++; 
   } 
   } 
  } 
 } 
 
?> 
 
         
     
  
              
        
		
				
		13 antwoorden 
                
                     
                
                    
		
		
	             
 
            
                    
                         
                    
                    
                        
                            NCube                             
                         
                     
                    
                        HTML beginner 
    
    
        
            
                <? $hoofdarray = array(
$sql = mysql_query("SELECT * FROM site_database_grootte");            
while($rij = mysql_fetch_assoc($sql))
{ 
$datum = $rij['datum'];
$grootte = $rij['grootte'];
$datum => $grootte
}
);?> 
             
            $sql  =  mysql_query ( "SELECT * FROM site_database_grootte" ) ;             {  
$datum  =  $rij [ 'datum' ] ; 
$grootte  =  $rij [ 'grootte' ] ; 
 
$datum  =>  $grootte 
} 
) ; ?> 
 
         
     
 
    
    
        
            
                <? $hoofdarray = array();
$sql = mysql_query("SELECT * FROM site_database_grootte");            
while($rij = mysql_fetch_assoc($sql)){ 
     $hoofdarray[$rij['datum']]=$rij['grootte'];
}
?> 
             
            <?  $hoofdarray  =  array ( ) ; $sql  =  mysql_query ( "SELECT * FROM site_database_grootte" ) ;                  $hoofdarray [ $rij [ 'datum' ] ] = $rij [ 'grootte' ] ; 
} 
?> 
 
         
     
   
                
                    
                         
                    
                    
                        
                            Frederic                             
                         
                     
                    
                        PHP ver gevorderde Hmm, nog steedsCitaat: 
De afbeelding “....” kan niet vertoond worden, omdat ze fouten bevat.
 
                      
                
                    
                         
                    
                    
                        
                            Fenrir                             
                         
                     
                    
                        PHP expert dit:
    
    
        
            
                header("Content-type: image/png"); 
             
            header ( "Content-type: image/png" ) ;  
         
     
  (op r. 24) moet je weghalen, dan zie je de php-errors. 
                      
                
                    
                         
                    
                    
                        
                            Fenrir (laatste wijziging 06/04/2005 14:56)                             
                         
                     
                    
                        PHP expert O, dan weet ik het niet. 
                      
                
                    
                         
                    
                    
                        
                            Thomas                             
                         
                     
                    
                        Moderator Misschien is dit een browser-specifiek probleem ? 
                      
                
                    
                         
                    
                    
                        
                            Frederic                             
                         
                     
                    
                        PHP ver gevorderde Hmm, nu krijg ik toch wel een error:
    
    
        
            
                $aantal = count($hoofdarray);
$interval = $gebied_breedte / ($aantal - 1);
$yinterval = $gebied_hoogte / $hoogste;
 
             
            $aantal  =  count ( $hoofdarray ) ; $interval  =  $gebied_breedte  /  ( $aantal  -  1 ) ; 
$yinterval  =  $gebied_hoogte  /  $hoogste ; 
 
         
     
   
                      
                
                    
                         
                    
                    
                        
                            mellowmood (laatste wijziging 06/04/2005 17:31)                             
                         
                     
                    
                        Nieuw lid ja gaat het op regel 2 verkeerd of op regel 3 in 
    
    
        
            
                $aantal = count($hoofdarray);
$interval = $gebied_breedte / ($aantal - 1);
$yinterval = $gebied_hoogte / $hoogste; 
             
            $aantal  =  count ( $hoofdarray ) ; $interval  =  $gebied_breedte  /  ( $aantal  -  1 ) ; 
$yinterval  =  $gebied_hoogte  /  $hoogste ; 
 
         
     
   
                      
                
                    
                         
                    
                    
                        
                            Frederic (laatste wijziging 06/04/2005 17:37)                             
                         
                     
                    
                        PHP ver gevorderde Jah ik zei al, m'n array klopt niet, maar
    
    
        
            
                <? $hoofdarray = array();
$sql = mysql_query("SELECT * FROM site_database_grootte");            
while($rij = mysql_fetch_assoc($sql)){ 
     $hoofdarray[$rij['datum']]=$rij['grootte'];
} ?>
 
             
            <?  $hoofdarray  =  array ( ) ; $sql  =  mysql_query ( "SELECT * FROM site_database_grootte" ) ;                  $hoofdarray [ $rij [ 'datum' ] ] = $rij [ 'grootte' ] ; 
}  ?> 
 
         
     
  
    
    
        
            
                
<?
//werkende array
$hoofdarray = array(
"1-1" => 45,
"2-1" => 35,
"3-1" => 42,
"4-1" => 46,
"5-1" => 51,
"6-1" => 49,
"7-1" => 33,
"8-1" => 39,
"9-1" => 40,
"10-1" => 34
); ?> 
             
            <? 
//werkende array 
"1-1"  =>  45 , 
"2-1"  =>  35 , 
"3-1"  =>  42 , 
"4-1"  =>  46 , 
"5-1"  =>  51 , 
"6-1"  =>  49 , 
"7-1"  =>  33 , 
"8-1"  =>  39 , 
"9-1"  =>  40 , 
"10-1"  =>  34 
) ;  ?> 
 
         
     
   
                      
                
                    
                         
                    
                    
                        
                            Fenrir (laatste wijziging 06/04/2005 18:04)                             
                         
                     
                    
                        PHP expert Er kunnen 2 dingen verkeerd zijn: 
                      
                
                    
                         
                    
                    
                        
                            Frederic                             
                         
                     
                    
                        PHP ver gevorderde Als ik print_r doe krijg ik:Citaat: 
Array ( [2005-02-14] => 2057 [2005-02-15] => 2078 [2005-02-16] => 2090 )
 
                      
                
                    
                         
                    
                    
                        
                            Fenrir                             
                         
                     
                    
                        PHP expert zet eens bovenaan: 
                      
                
                    
                         
                    
                        
		
		
	             
 
                
Dit onderwerp is gesloten .