我正在处理一些问题,我有一个HTML页面,它做表单输入,并采用两个值(开始日期和结束日期),然后使用post方法我发布这些值在sql语句生成图我。我也试图从sql表中打印一些内容,即我想打印表的列的平均值,我试过了
这里是表单输入代码:
enter code here
Enter_Start_Date:
Enter_End_Date:
Enter_Type:
Enter_Type:
这里是test.php,它应该在同一页面上显示图形和打印平均值,当我执行此代码时,它会在webapge上显示一些垃圾信息:
include("phpgraphlib.php");
$graph = new PHPgraphLib(1000,1000);
$host = 'host';
$port = '3306';
$server = $host . ':' . $port;
$user = 'root'; $password = 'root';
$link = mysql_connect ($server, $user, $password);
if (!$link)
{
die('Error: Could not connect: ' . mysql_error());
}
$database = 'jira';
mysql_select_db($database);
$query = ("select pkey, numbervalue
from jiraissue ji
join customfieldvalue cf on ji.id = cf.issue
join resolution r on ji.resolution = r.id
join issuestatus isst on ji.issuestatus = isst.id
join issuetype isstype on ji.issuetype = isstype.id
join label lb on ji.id = lb.issue
where numbervalue is not null
and isstype.pname in ('Ticket')
and lb.label in ('$_POST[pkey3]', ' $_POST[pkey4]')
and ji.updated between '$_POST[pkey1]' and '$_POST[pkey2]'");
$result = mysql_query($query);
if ($result) {
while ($row = mysql_fetch_assoc($result)) {
$customvalue=$row["pkey"];
$count=$row["numbervalue"];
//add to data array
$dataArray[$customvalue]=$count;
}
}
//configure graph
$graph->addData($dataArray);
$graph->setTitle("test");
$graph->setGradient("lime", "green");
$graph->setBarOutlineColor("black");
$graph->createGraph();
?>
include("phpgraphlib.php");
$graph = new PHPgraphLib(1000,1000);
$host = 'host';
$port = '3306';
$server = $host . ':' . $port;
$user = 'root'; $password = 'root';
$link = mysql_connect ($server, $user, $password);
if (!$link)
{
die('Error: Could not connect: ' . mysql_error());
}
$database = 'jira';
mysql_select_db($database);
$query = ("select avg(numbervalue) as avg_hrs
from jiraissue ji
join customfieldvalue cf on ji.id = cf.issue
join resolution r on ji.resolution = r.id
join issuestatus isst on ji.issuestatus = isst.id
join issuetype isstype on ji.issuetype = isstype.id
join label lb on ji.id = lb.issue
where numbervalue is not null
and isstype.pname in ('Certification Ticket')
and lb.label in ('$_POST[pkey3]', ' $_POST[pkey4]')
and ji.updated between '$_POST[pkey1]' and '$_POST[pkey2]'");
$result = mysql_query($query);
if (!$result)
{
$message = 'ERROR:' . mysql_error();
return $message;
}
else
{
$i = 0;
echo ' ';
while ($i < mysql_num_fields($result))
{
$meta = mysql_fetch_field($result, $i);
echo ' ' . $meta->name . ' ';
$i = $i + 1;
} echo ' ';
$i = 0;
while ($row = mysql_fetch_row($result))
{
echo ' '; $count = count($row);
$y = 0;
while ($y < $count)
{
$c_row = current($row);
echo ' ' . $c_row . ' ';
next($row);
$y = $y + 1;
}
echo ' ';
$i = $i + 1;
} echo ' ';
mysql_free_result($result);
}
?>