Jump to content

Problem with Graph Include


SalientAnimal

Recommended Posts

Hi Guys/Gals

 

So I have this nice little page displaying a table with information. I would like to also display graphs below the table. I have managed to get the graph to represent one kind of data, and will get to it displaying more once I get the include working.

 

The php file for the graph displays fine when on its own, as does the table page. The problem is when I try to include the Graph, get the table displaying, and a whole lot of junk thrown out at the bottom instead of the graph. I must apologise as I know my code isn't the cleanest, but it is all self taught.

 

 

Can someone help me here perhaps?

 

Here is my code for the table:

I must apologise as I know my code isn't the cleanest, but it is all self taught.

<?php

session_start();
$conn = @mysql_connect("localhost","root","MYPASSWORD") or exit("Could not establish a connection to MySQL Server. mysql_error()");
$select = @mysql_select_db("MYDATABASE",$conn) or exit("Could not select the appropriate database for this operation. mysql_error()");

if(isset($_COOKIE['ID_my_site']))
{
    $username = $_COOKIE['ID_my_site'];
    $name = $_COOKIE['ID_my_name'];	
    $pass = $_COOKIE['Key_my_site'];
    $check = @mysql_query("SELECT * FROM userinfo WHERE username='$username'") or die("Failed to execute SQL Statement.");
    while($info = mysql_fetch_array($check))
    {
        if($pass != $info['password'])
        {
            header("Location: login.php");
        }
        else{

	}
}
}
else{
    header("Location:login.php");
}

include "navigation/churn.html";
?>

<title> ? 2012 Initiator Log </title>
<meta http-equiv="refresh" content="10">
<script type="text/javascript">
var count = 0;
var delay = 250;
var text = "? 2012 Churn Management                                ";
function scroll () {
  document.title = text.substring(count, text.length) + text.substring (0, count)
  if (count < text.length) {
    count ++;
  } else {
    count = 1;
  }
  setTimeout ("scroll()", delay);
}
scroll();
</script>
<LINK REL="SHORTCUT ICON" HREF="favicon.ico">

<script language="javascript" src="js/admin.js"></script>




<style type="text/css">
<!--
#form1 table tr td {
color: #FFF;
}
#form1 table tr td {
font-family: "Segoe Print", Tahoma, "Segoe UI";
font-size: 13px;
}
#form1 p {
color: #FFF;
font-size: 36px;
font-weight: bold;
text-align: center;
font-family: "Segoe Print", Tahoma, "Segoe UI";
}
-->
</style>
</head>
<link rel="stylesheet" type="text/css" href="/css/layout_churn.css"/>
</head>

<html>
<table width="100%" border="0">
  <tr>
    <td width="20%"></td>
    <td width="80%"><p align="justify"></p></td>
  </tr>
  <tr>	
    
<p>Input 
the Reference, to make sure we have the right one:<br>
(Quick Search Listed Below)</p>

<form method=post action="http://10.249.135.30/search_updates/amend_churn_i.php">
<input type="text" name="record" size="50">
<br>
<img src="images/find.png" alt="find">
<input type="submit" name="search" value="Search">
</form>

<?php
// Show simple format of the records so person can choose the reference name/number
// this is then passed to the next page, for all details

$con = mysql_connect("localhost"
,"root"
,"MYPASSWORD");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  
mysql_select_db("MYDATABASE", $con);

$sql="SELECT 
staff_churn.reference
, staff_churn.champ
, staff_churn.churn_type
, staff_churn.effective_date
, staff_churn.department
, staff_churn.exit_department
, staff_churn.position
, staff_churn.contract_type
, staff_churn.status
, TIMESTAMPDIFF(DAY, sys_date,NOW()) AS days
, SEC_TO_TIME(TIMESTAMPDIFF(SECOND,sys_date,NOW()) MOD 86400) AS current_tat
FROM staff_churn
WHERE staff_churn.username='$username'
";

$result = mysql_query( $sql)
or die(" - Failed More Information:<br><pre>$sql</pre><br>Error: " . mysql_error());

$num_rows = mysql_num_rows($result);
if ($myrow = mysql_fetch_array($result)) {

echo "<br><p>Outstanding Churn Management - Initiator Log<BR></p><br>";
echo "<table border=1>\n";
echo "<tr>
<td bgcolor=#444444 align=center><p><b>Reference</p></td>
<td bgcolor=#444444 align=center><p><b>Champ</p></td>
<td bgcolor=#444444 align=center><p><b>Churn Type</p></td>
<td bgcolor=#444444 align=center><p><b>Effective Date</p></td>
<td bgcolor=#444444 align=center><p><b>Department</p></td>
<td bgcolor=#444444 align=center><p><b>Exit Department</p></td>
<td bgcolor=#444444 align=center><p><b>Position</p></td>
<td bgcolor=#444444 align=center><p><b>Contract Type</p></td>
<td bgcolor=#444444 align=center><p><b>Status</p></td>
<td bgcolor=#444444 align=center><p><b>Days</p></td>
<td bgcolor=#444444 align=center><p><b>HH:MM:SS</p></td>

</tr>\n";
do {




printf("<tr>
<td><p>%s</p></td>
<td><p>%s</p></td>
<td><p>%s</p></td>
<td><p>%s</p></td>
<td><p>%s</p></td>
<td><p>%s</p></td>
<td><p>%s</p></td>
<td><p>%s</p></td>
<td><p>%s</p></td>
<td><p>%s</p></td>
<td><p>%s</p></td>
</tr>\n"
,$myrow["reference"]
,$myrow["champ"]
,$myrow["churn_type"]
,$myrow["effective_date"]
,$myrow["department"]
,$myrow["exit_department"]
,$myrow["position"]
,$myrow["contract_type"]
,$myrow["status"]
,$myrow["days"]
,$myrow["current_tat"]
);








} while ($myrow = mysql_fetch_array($result));
echo "</table>\n";
} else {
echo "$ref There are currently no pending actions"; 
} 

mysql_free_result($result);
mysql_close($con);



?>
</html>
<?php

 

And the code for the graph:

<?php   

include("graphlib/phpgraphlib.php");  

$graph=new PHPGraphLib(550,400); 


$link = mysql_connect('localhost', 'root', 'MYPASSWORD')  

   or die('Could not connect: ' . mysql_error());  

      

mysql_select_db('MYDATABASE') or die('Could not select database');  

   

$dataArray=array();  

   

//get data from database  

$sql="SELECT reference, 
COUNT(*) AS 'queries' FROM staff_churn 
WHERE status = 'Open'
GROUP BY status";  

$result = mysql_query($sql) or die('Query failed: ' . mysql_error());   

if ($result) {  

  while ($row = mysql_fetch_assoc($result)) {   

      $status=$row["Open Query"];  

      $count=$row["queries"];  

      //add to data areray  

      $dataArray[$status]=$count;  

  }  

}  

   

//configure graph  

$graph->addData($dataArray);  


$graph->setTitle("Open Queries");
  
$graph->setTextColor("black");

$graph->setGradient("red", "maroon"); 

$graph->setBarOutlineColor("black");  

$graph->createGraph();  

?> 

Link to comment
https://forums.phpfreaks.com/topic/264878-problem-with-graph-include/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.