【php开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了php开源代码-saletable.php的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
<?php
if (isset($_POST['Submit']))
{
// 读取获取数据
$data = array($_POST['T1'],$_POST['T2'],$_POST['T3'],$_POST['T4'],$_POST['T5']);
$x_fld = array('Jan','Feb','March','April','May');
$max = 0;
for ($i=0;$i<5;$i++)
{
if ($data[$i] > $max)$max=$data[$i]; //找出最大的日期值
}
//创建一个320*225的图象
$im = imagecreate(320,255);
//设定颜色
$white = imagecolorallocate($im,255,255,255);
$black = imagecolorallocate($im,0,0,0);
$red = imagecolorallocate($im,255,0,0);
$green = imagecolorallocate($im,0,255,0);
$blue = imagecolorallocate($im,0,0,255);
// 创建一个背景
//画图
imageline($im, 10, 5, 10, 230, $blue );
imageline($im, 10, 230, 300, 230, $blue );
//确定X、Y坐标
imagestring($im,3,8,2,"Y",$black);
imagestring($im,3,305,222,"X",$black);
//画出下一个点是什么
$x = 15; // x1点的位置
$y = 230; // Y1点的位置
$x_width = 20; // 宽度
$y_ht = 0; // 高度
// 通过for循环确定图形
for ($i=0;$i<5;$i++){
$y_ht = ($data[$i]/$max)* 100; // 最大月份的记录
imagerectangle($im,$x,$y,$x+$x_width,($y-$y_ht),$red);
imagestring( $im,2,$x-1,$y+1,$x_fld[$i],$black);
imagestring( $im,2,$x-1,$y+10,$data[$i],$black);
$x += ($x_width+20); // 月份图形之间的距离
}
//输出图象
imagejpeg( $im, "mypic.jpeg", 90);
//清除资源
imagedestroy($im);
echo "<img src='mypic.jpeg'><p></p>";
}
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<title>Sales Report</title></head>
<body>
<form method="POST" name="myForm">
<div align="left">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="454" height="159">
<tr>
<td width="454" height="32" colspan="2" bgcolor="#CCCCCC">
<p align="left"><b><font face="Tahoma">销售
报告:</font></b></td>
</tr>
<tr>
<td width="207" height="41">
<p align="right"><b><font face="Tahoma" size="2">一月份:</font></b></td>
<td width="241" height="41"><input type="text" name="T1" size="6"></td>
</tr>
<tr>
<td width="207" height="44">
<p align="right"><b><font face="Tahoma" size="2">二月份:</font></b></td>
<td width="241" height="44"><input type="text" name="T2" size="6"></td>
</tr>
<tr>
<td width="207" height="35" align="right"><strong><font size="2" face="Tahoma">三月份:</font></strong></td>
<td width="241" height="35"><input type="text" name="T3" size="6"></td>
</tr>
<tr>
<td width="207" height="35" align="right"><strong><font size="2" face="Tahoma">四月份:</font></strong></td>
<td width="241" height="35"><input type="text" name="T4" size="6"></td>
</tr>
<tr>
<td width="207" height="35" align="right"><strong><font size="2" face="Tahoma">五月份:</font></strong></td>
<td width="241" height="35"><input type="text" name="T5" size="6"></td>
</tr>
<tr>
<td width="448" height="35" align="right" colspan="2">
<p align="center"><font face="Tahoma">
<input type="submit" value="确定" name="Submit"></font></td>
</tr>
</table>
</div>
</form>
</body>
</html>