销售柱状图
************************************
我感觉是不是 表单中的数值没有传过来哦??
*************************************
input.html
*************************************
<html>
<head>
<title>销售报表</title>
<style type="text/css">
<!--
.STYLE1 {color: #990033}
-->
</style>
</head>
<body>
<div align="center">
<form method="post" action="default.php" name="report forms" id="report forms">
  <h1 class="STYLE1">销售报表</h1>
  <table align="center">
    <tr>
                <td>一月份商品总销售额:<input type="text"name="t1"size="10"></td>    
                <td>  七月份商品总销售额:   
                  <input type="text"name="t7"size="10"></td>
   </tr>
   <tr>
<td>二月份商品总销售额:<input type="text"name="t2"size="10"></td>    <td>  八月份商品总销售额:  <input type="text"name="t8"size="10"></td>
   </tr>
   <tr>
<td>三月份商品总销售额:<input type="text"name="t3"size="10"></td>    <td>  九月份商品总销售额:  <input type="text"name="t9"size="10"></td>
   </tr>
   <tr>
<td>四月份商品总销售额:<input type="text"name="t4"size="10"></td>    <td>  十月份商品总销售额:  <input type="text"name="t10"size="10"></td>
   </tr>
   <tr>
<td>五月份商品总销售额:<input type="text"name="t5"size="10"></td>    <td>十一月份商品总销售额:<input type="text"name="t11"size="10"></td>
   </tr>
   <tr>
<td>六月份商品总销售额:<input type="text"name="t6"size="10"></td>    <td>十二月份商品总销售额:<input type="text"name="t12"size="10"></td>
   </tr>
</table>
  <p>
    <label>
      <input type="Submit" name="Submit" value="提交">
    
    </label>
  </p>
</form>
</div>
<body>
</html>
***********************************************************************************
default.php
************************************************************************************
<?php
if($_post["Submit"]!=""){
$data=array($_POST["t1"],$_POST["t2"],$_POST["t3"],$_POST["t4"],$_POST["t5"],
$_post["t6"],$_POST["t7"],$_POST["t8"],$_POST["t9"],$_POST["t10"],$_POST["t11"],
$_post["t12"],);
$month=array("Jan","Feb","March","April","May","June","July","Aug","Sep","Oct","Nov","Dec");
$max=0;
for($i=0;$i<12;$i++){
$max+=$data[$i];     //商品的累加
}
$im=imagecreate(520,350);
$green=imagecolorallocate($im,214,235,214); //设置颜色
$red=imagecolorallocate($im,255,0,0);
$black=imagecolorallocate($im,0,0,0);
$bule=imagecolorallocate($im,0,0,255);

imageline($im,10,5,10,230,$blue);  //x轴坐标
imageline($im,10,230,500,230,$blue);  //y轴坐标
imagestring($im,3,8,1,"Y",$black);  //8,1位置 为坐标点
imagestring($im,3,502,222,"X",$black); //Y字符 输出 3为  字形 1-5

$l=190;
$k1=10;
$k2=490;
for($j=0;$j<12;$j++){
imageline($im,$k1,$l,$k2,$l,$black);  //实线绘制(x1,y1)-(x2,y2)(0.0)为坐上原点
$l=$l-40;
}

$f=50;
$z1=10;
$z2=490;
for($j=0;$j<12;$j++){
imageline($im,$f,$z1,$f,$z2,$black); //实线绘制(x1,y1)-(x2,y2)(0.0)为坐上原点
$f=$f+40;
}

$x=20;
$y=230;
$x_width=20;
$y_ht=0;
for ($i=0;$i<12;$i++){
$y_ht=($data[$i]/$max)*1000;  //设置商品销量所占千分比
imagefilledrectangle($im,$x,$y,$x+$x_width,($y-$y_ht),$red);
imagestring($im,2,$x-1,$y+1,$month[$i],$black);
imagestring($im,2,$x-1,$y+15,$data[$i],$black);
$x+=($x_width+20);
}
imagepng($im,"a.png");
echo "<img src='a.png'>";
imagedestroy($im);
}
?>
***********************************************************************************
反正 单击 提交·· PHP 中没有 显示 图形, 请高手帮帮忙 看看··· 谢谢~~~~~

解决方案 »

  1.   

    $_post["Submit"]是空值,程序不会进入if里面。你改个判断条件吧。销售柱状图的计算机貌似还有点问题
      

  2.   

    把default.php改成下面的。
    <?php
    $data=array($_POST["t1"],$_POST["t2"],$_POST["t3"],$_POST["t4"],$_POST["t5"],$_post["t6"],$_POST["t7"],$_POST["t8"],$_POST["t9"],$_POST["t10"],$_POST["t11"],$_post["t12"],);
    $month=array("Jan","Feb","March","April","May","June","July","Aug","Sep","Oct","Nov","Dec");
    $max=0;
    for($i=0;$i <12;$i++){
    $max+=$data[$i];     //商品的累加
    }
    $im=imagecreate(520,350);
    $green=imagecolorallocate($im,214,235,214); //设置颜色
    $red=imagecolorallocate($im,255,0,0);
    $black=imagecolorallocate($im,0,0,0);
    $bule=imagecolorallocate($im,0,0,255);imageline($im,10,5,10,230,$blue);  //x轴坐标
    imageline($im,10,230,500,230,$blue);  //y轴坐标
    imagestring($im,3,8,1,"Y",$black);  //8,1位置 为坐标点
    imagestring($im,3,502,222,"X",$black); //Y字符 输出 3为  字形 1-5$l=190;
    $k1=10;
    $k2=490;
    for($j=0;$j <12;$j++){
    imageline($im,$k1,$l,$k2,$l,$black);  //实线绘制(x1,y1)-(x2,y2)(0.0)为坐上原点
    $l=$l-40;
    }$f=50;
    $z1=10;
    $z2=490;
    for($j=0;$j <12;$j++){
    imageline($im,$f,$z1,$f,$z2,$black); //实线绘制(x1,y1)-(x2,y2)(0.0)为坐上原点
    $f=$f+40;
    }$x=20;
    $y=230;
    $x_width=20;
    $y_ht=0;
    for ($i=0;$i <12;$i++){
    $y_ht=($data[$i]/$max)*1000;  //设置商品销量所占千分比
    imagefilledrectangle($im,$x,$y,$x+$x_width,($y-$y_ht),$red);
    imagestring($im,2,$x-1,$y+1,$month[$i],$black);
    imagestring($im,2,$x-1,$y+15,$data[$i],$black);
    $x+=($x_width+20);
    }
    imagepng($im,"a.png");
    echo " <img src='a.png'>";
    imagedestroy($im);
    ?> 
      

  3.   

    或者你可以写成以下格式:
    <?php
    if(isset($_POST["Submit"])){
    $data=array($_POST["t1"],$_POST["t2"],$_POST["t3"],$_POST["t4"],$_POST["t5"],$_post["t6"],$_POST["t7"],$_POST["t8"],$_POST["t9"],$_POST["t10"],$_POST["t11"],$_post["t12"],);
    $month=array("Jan","Feb","March","April","May","June","July","Aug","Sep","Oct","Nov","Dec");
    $max=0;
    for($i=0;$i <12;$i++){
    $max+=$data[$i];     //商品的累加
    }
    $im=imagecreate(520,350);
    $green=imagecolorallocate($im,214,235,214); //设置颜色
    $red=imagecolorallocate($im,255,0,0);
    $black=imagecolorallocate($im,0,0,0);
    $bule=imagecolorallocate($im,0,0,255);imageline($im,10,5,10,230,$blue);  //x轴坐标
    imageline($im,10,230,500,230,$blue);  //y轴坐标
    imagestring($im,3,8,1,"Y",$black);  //8,1位置 为坐标点
    imagestring($im,3,502,222,"X",$black); //Y字符 输出 3为  字形 1-5$l=190;
    $k1=10;
    $k2=490;
    for($j=0;$j <12;$j++){
    imageline($im,$k1,$l,$k2,$l,$black);  //实线绘制(x1,y1)-(x2,y2)(0.0)为坐上原点
    $l=$l-40;
    }$f=50;
    $z1=10;
    $z2=490;
    for($j=0;$j <12;$j++){
    imageline($im,$f,$z1,$f,$z2,$black); //实线绘制(x1,y1)-(x2,y2)(0.0)为坐上原点
    $f=$f+40;
    }$x=20;
    $y=230;
    $x_width=20;
    $y_ht=0;
    for ($i=0;$i <12;$i++){
    $y_ht=($data[$i]/$max)*1000;  //设置商品销量所占千分比
    imagefilledrectangle($im,$x,$y,$x+$x_width,($y-$y_ht),$red);
    imagestring($im,2,$x-1,$y+1,$month[$i],$black);
    imagestring($im,2,$x-1,$y+15,$data[$i],$black);
    $x+=($x_width+20);
    }
    imagepng($im,"a.png");
    echo " <img src='a.png'>";
    imagedestroy($im);
    }
    ?> 
      

  4.   

    if(isset($_POST["Submit"]))
    -----------
    类似的情况,要避免用你所认为的$_POST["Submit"]!="",尽量使用PHP的函数,例:empty($_POST["Submit"])或isset($_POST["Submit"])