I've been toying around with this for awhile to make it as simple and fast as possible.
<?php
if(!$odbc['connection'] = odbc_connect('DNS','USER','PASS'))
{
exit("Connection Failed<br />\n");
}
else
{
echo("Connected<br />\n");
}
$odbc['table'] = "table";
if($result = odbc_exec($odbc['connection'],"select * from $odbc['table'];"))
{
for($i = 1;$i <= odbc_num_fields($result);$i++)
{
$odbc['rows']['fields'][$i] = odbc_field_name($result,$i);
}
unset($i);
odbc_free_result($result);
}
else
{
exit("Error in SQL Query");
}
if(odbc_close($odbc['connection']))
{
odbc_close($odbc['connection']);
}
if(!empty($odbc['rows']))
{
print_r($odbc['rows']);
}
?>