I have data within a MySQL DB and i have connected it to a chart application so that the charts are dynamic. This bit is sorted but i want to be able to filter the data so for instance, click on the temperature box, press submit and the only the temperature chart would show up.
I am having two problems at the moment. The temperature field has three rows of data. I have no problems showing the data within the chart but three charts are also produced.This is obviously because i have 3 rows of data.
The second problem is i cannot get the charts to appear when a particular box has been checked.At the moment if all the boxes are empty & i press submit. The charts still show up so i thought i would check the boxes to see if the charts would disappear but they dont so i cannot reverse the coding.
Here is the involved coding for the form and proccessed page.
FORM
echo "<table border=0 cellpadding=2 cellspacing=2>";
echo "<form action=$_SERVER[PHP_SELF] method=REQUEST>";
echo "<tr>";
echo "<td><h3><font face=Verdana size=-1>Please choose the desired tool<p><font size=-1> (tool - job # - company rep)</h3></td></tr>";
echo "<td>";
echo "<select width=20 name=oldCharts>";
while ($row=mysql_fetch_assoc($sresult)){
echo "<option value=$row[job_num]>$row[name] - $row[job_num] - $row[company_rep]</option>";
#echo "<td>".$row[name]."</td>";
}
echo "</select>";
echo "</td>";
echo "<td></td><td></td>";
echo "<td>Temperature</td> <td><p align=center><input type=checkbox name=temp value=showhide></center></td>";
echo "</form>";
PROCESSED SITE
foreach ($_REQUEST as $oldCharts => $job_num){
if ($hrs_run && $oldCharts && $job_num = 'submit'){
exit();
}
$charts = sprintf("SELECT * FROM tool_data WHERE job_num = %s", quote_smart($job_num));
$cresult = mysql_query($charts) or die ("ERROR:Unable to run charts");
$toolhrschart = new HorizontalChart(600,250);
while ($row_data = mysql_fetch_array($cresult)){
$well_name = $row_data['well_name'];
$hrs_run = $row_data['hrs_run'];
$toolhrschart -> addPoint(new Point("Well: $well_name","$hrs_run"));
$toolhrschart -> setTitle("tool Hours");
$toolhrschart ->render("graphs/toolhrs$row_data[job_num]$row_data[company_rep].png");
echo "<img alt =$row_data[name]-$row_data[company_rep] src=graphs/toolhrs$row_data[job_num].png style=border:1px solid black />";
}
}
echo "<br />";
echo "<font size=-1><a href = http://localhost/filtering/oldfts.php>Back</a>";
}
Thanks