duanba5777 2016-03-13 17:17
浏览 39

嵌入jpgraph与其他PHP

I have a php page that is dependent on the previous page. Depending on the type of customer i click on so will i see their information on the next page. I now have a problem that I must have the graph embeded into the php page to retrieve SQL data just for that customer. Because if I have the graph on a separate PHP page it doesnt know which customer I click on to display their statistic.

How do i embed jpgraph into with other php?

PHP

<?php

// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($mysqli,"SELECT rid, pid, firstname, lastname, email FROM temp_members_db WHERE pid='$pid1' ");

echo "<table><tr><th>Namn</th><th>E-mail</th><th>Resultat</th><th>Ta bort kandidat</th></tr>";
while($row = mysqli_fetch_array($result))
{

$count= "SELECT COUNT(qid) AS 'Total' FROM result WHERE rid=".$row['rid']."";
$result01 = mysqli_query($mysqli, $count); 
$resultArr01 = mysqli_fetch_array($result01);
$total= $resultArr01[0]*10;

$pointsummary= "SELECT SUM(points) AS 'Summary' FROM result WHERE rid=".$row['rid']."";
$result02 = mysqli_query($mysqli, $pointsummary);
$resultArr02 = mysqli_fetch_array($result02);

$sum= $resultArr02[0];

$result00 = ($total != 0 ? round($sum/$total*100) : 0);
  
    

    
    $color = "#000000";

if (($result00 >= 1) && ($result00 <= 30))
   $color = "#FF0000";
else if (($result00 > 30) && ($result00 <= 60))
   $color = "#FF9900";
else if (($result00 > 60) && ($result00 <= 100))
   $color = "#07d407";

echo "<tr><td><strong>
<form action='/devlopment/graph.php' method='GET'>
 <input type='hidden' name='rid' value='".$row['rid']."'>
 <input type='hidden' name='firstname' value='".$row['firstname']."'> 
<input type='submit' class='resname' name='submit' value='".$row['firstname']." ".$row['lastname']."'>

 </form>
 </strong></td> 
 <td>".$row['email']."</td> 
 <td><strong><span style=\"color: $color\">".$result00."</span>%</strong></td>   
 
 <form action='deleterespondent2.php' method='post'>
 <input type='hidden' name='rid' value='".$row['rid']."'> 
<td> <input type='submit' class='mydel' value='Radera' onclick=\"return confirm('Vill du verkligen radera kandidaten? \
\
Observera att kandidatens eventuellt besvarade frågor och resultat raderas också!')\">
 </form>
</td></tr>";

}
echo "</table>";
mysqli_close($mysqli);
?>

graph

<?php 
require_once('jpgraph/jpgraph.php');  
require_once('jpgraph/jpgraph_line.php');  
require_once('jpgraph/jpgraph_bar.php'); 
session_start();
$val = (isset($_GET['rid']))  ? 
    "{$_GET['rid']}" : '';  
 
$x_axis = array();  
$y_axis = array();  
$i      = 0;  
$con    = mysqli_connect("root", "g", "f", "d");  
// Check connection  
if (mysqli_connect_errno()) {  
    echo "Failed to connect to MySQL: " . mysqli_connect_error();  
}  
$result = mysqli_query($con, "SELECT * FROM result WHERE rid=$val");  
while ($row = mysqli_fetch_array($result)) {  
    $x_axis[$i] = $row["qid"];
    $y_axis[$i] = $row["points"];
    $i++;  
}  


mysqli_close($con);  
$width  = 600;  
$height = 200;  
$graph  = new Graph($width, $height);  
$graph->SetScale('textint');  
$graph->title->Set('My Example');  
$graph->xaxis->title->Set('(Fråga)');  
$graph->xaxis->SetTickLabels($x_axis);  
$graph->yaxis->title->Set('(Poäng)');  
$barplot = new BarPlot($y_axis);  
$graph->Add($barplot);  
$graph->Stroke();
?>

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 软件测试决策法疑问求解答
    • ¥15 win11 23H2删除推荐的项目,支持注册表等
    • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
    • ¥15 qt6.6.3 基于百度云的语音识别 不会改
    • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
    • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
    • ¥15 lingo18勾选global solver求解使用的算法
    • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
    • ¥20 测距传感器数据手册i2c
    • ¥15 RPA正常跑,cmd输入cookies跑不出来