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>