【php开源代码栏目提醒】:本文主要为网学会员提供sales.php,希望对需要sales.php网友有所帮助,学习一下!
<?php
if (isset($_POST['Submit'])){
// read the post data
$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]; // find the largest data
}
$im = imagecreate(320,255); // width , height px
$white = imagecolorallocate($im,255,255,255); // allocate some color from RGB components remeber Physics
$black = imagecolorallocate($im,0,0,0); //
$red = imagecolorallocate($im,255,0,0); //
$green = imagecolorallocate($im,0,255,0); //
$blue = imagecolorallocate($im,0,0,255); //
//
// create background box
//imagerectangle($im, 1, 1, 319, 239, $black);
//draw X, Y Co-Ordinate
imageline($im, 10, 5, 10, 230, $blue );
imageline($im, 10, 230, 300, 230, $blue );
//Print X, Y
imagestring($im,3,8,2,"Y",$black);
imagestring($im,3,305,222,"X",$black);
// what next draw the bars
$x = 15; // bar x1 position
$y = 230; // bar $y1 position
$x_width = 20; // width of bars
$y_ht = 0; // height of bars, will be calculated later
// get into some meat now, cheese for vegetarians;
for ($i=0;$i<5;$i++){
$y_ht = ($data[$i]/$max)* 100; // no validation so check if $max = 0 later;
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); // 20 is diff between two bars;
}
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">Sales Report:</font></b></td>
</tr>
<tr>
<td width="207" height="41">
<p align="right"><b><font face="Tahoma" size="2">January:</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">February:</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"><b>
<font face="Tahoma" size="2">March:</font></b></td>
<td width="241" height="35"><input type="text" name="T3" size="6"></td>
</tr>
<tr>
<td width="207" height="35" align="right"><b>
<font face="Tahoma" size="2">April:</font></b></td>
<td width="241" height="35"><input type="text" name="T4" size="6"></td>
</tr>
<tr>
<td width="207" height="35" align="right"><b>
<font face="Tahoma" size="2">May:</font></b></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="Submit" name="Submit"></font></td>
</tr>
</table>
</div>
</form>
<?php
echo "<font face=Tahoma size=2>Visit <a href='http://ialsoblog.blogspot.com/'>I Also Blog</a></b><br>";
echo "Dont forget to Vote for me if u lyk d code :-)</font></b><br>";
?>
</body>
</html>