Hi,
I need help with writing a PHP program to extract data from a HTML table and plot a simple X-Y line graph. I already have GD enabled in my PHP so no problems there.
The HTML table is derived by using a PHP file that queries a PostgreSQL database. for the data. The user then should have the ability to select which columns in the tables he wants as the X and Y axis in the graph, and then the program should generate the graph.
The code used to create the HTML looks like this:
$result = pg_query($pgsql_conn, "select * from q25");
function table_create($result)
{
$numrows = pg_num_rows($result);
$fnum = pg_num_fields($result);
echo "<table border width='100%'>";
echo "<tr>";
for ($x = 0; $x < $fnum; $x++) {
echo "<td><b>";
echo strtoupper(pg_field_name($result, $x));
echo "</b></td>";
}
echo "</tr>";
for ($i = 0; $i < $numrows; $i++) {
$row = pg_fetch_object($result, $i);
echo "<tr align='center'>";
for ($x = 0; $x < $fnum; $x++) {
$fieldname = pg_field_name($result, $x);
echo "<td>";
echo $row->$fieldname;
echo "</td>";
}
echo"</tr>";
}
echo "</table>";
return 0;
}
table_create($result);
Can anyone suggest how I can go about this? I'm a PHP newbie here and my searches on the Web hasn't returned any results that I can understand.
Thanks in advance.
Rishirish