I have to create a generic query result page that, given the certain pieces of information and an SQL query (SELECT)statement, retrieves the results,
and prints the information in a table, with table headings, graphs, etc as
specified in the information given.Information supplied to query result page.
SELECT STATEMENT
Table Headings - Supplied, if none supplied for a given value, use SQL fieldname
Graph type = Strip, Bar, PieGraph Elements = SQL Result fields to use for graph
I have looked everywhere and can't find anything that will do anything remotely similar to this.
I have to use HTML within PHP and that PHP within another HTML, right? The dayabase I am working with is ODBC. How would I go about doing this.
This is what I have so far. Doesn't work. What am I doing wrong?
<HEAD><TITLE>Web Reporting Module</TITLE>
</HEAD><H3>Web Reporting Module</H3>
<FORM ACTION="testphp.php" METHOD=GET">
Enter Informtion: <INPUT TYPE=text NAME=info_table><P>
<INPUT TYPE=submit
VALUE="Retreive Information">
<?php
function db_connect() {
global $db_type,$db_name,$db_port,$db_host,$db_user,$db_password);
$handle = pg_connect($db_type, $db_name, $db_port, $db_host, $db_user, $db_password);
if (!$handle) {
echo db_error();
}
return $handle;
}
$result = pg_query($handle, "select , count() from $table");
include( "class.php3");
$table=info_table;
Function GraphResult($result,$head) {
$rows=pg_numrows($result);
if ((!$result) || ($rows < 1)) {
echo "No Information Found./n";
}
for ($i=0; $i < pg_numrows($result); $i++){
if (pg_result($result, $i, 0) != "" && pg_result($result, $i, 1) != "") {
$names[$i]= pg_result($result, $i, 0);
$values[$i]= pg_result($result, $i, 1);
}
}
GraphIt($names,$values,$head);
}
}
Function GraphIt($names,$values,$head)
{
$counter=count($names);
for ($j = 0; $j < $counter; $j++) {
$bars[$j]= "#DEDEEE";
}
$counter=count($values);
$max_value=0;
for ($j = 0; $j < $counter; $j++) {
if ($values[$i] > $max_value) {
$max_value=$values[$j];
}
}
if ($max_value < 1) {
$max_value=1;
}
$scale = (int) (800/$max_value);
echo "<TABLE BCOLOR="NAVY" CELLSPACING=2 CELLPADDING=3>";
echo "<TR><TD BGCOLOR="NAVY"><FONT COLOR=WHITE><B>Table</TD></TR><TR><TD>";
html_graph($names,$values,$bars,$vals);
echo "</TD></TR></TABLE>";
}
?>