<?php
/*Program: results.php
*Desc: PHP program that sends an SQL query to the
* MySQL server and displays the results of offsetters database.
*/
echo "<html>
<head><title>Offsetters Results</title></head>
<body>";


if(ini_get("magic_quotes_gpc") == "1")
{
$_POST['query'] = stripslashes($_POST['query']);
}

$host="mysql103.mysite4now.com";
$user="external";
$password="ocns";
$database="ocns_calculator";
$table = "offsets";
$query = "SELECT * FROM ". $table ;
/* Section that executes query and displays the results */ 
$cxn = mysql_connect($host,$user,$password);
mysql_select_db($database);
$result = mysql_query($query,$cxn);
echo"<h3>Results</h3><hr>";
if($result == false)
{
echo "<h4>Error: ".mysql_error($cxn)."</h4>";
}
elseif(@mysql_num_rows($result) == 0)
{
echo "<h4>Query completed.
No results returned.</h4>";
}
else
{
/* Display results */
echo "<table border='1'><thead><tr>";
for($i = 0;$i < mysql_num_fields($result);$i++)
{
echo "<th>".mysql_field_name($result,$i).
"</th>";
}
echo "</tr></thead>
<tbody>";
for ($i=0;$i < mysql_num_rows($result);$i++)
{
echo "<tr>";
$row = mysql_fetch_row($result);
foreach($row as $value)
{
echo "<td>".$value."</td>";
}
echo "</tr>";
}
echo "</tbody></table>";
//exit();
}
/* Displays form for query input */

?>
	   <br/><p>
<a href="report.php" title="New" accesskey="n" target="_self">New Report</a>
</p>
</body></html>




