None of these examples were working for me, so I came up with the following silly procedure that gives me the number of rows. This example is crude, but you should get the idea.
<?php
$cxn = odbc_connect("ODBC_DSN_NAME", "", "");
$sql = "SELECT * FROM some_table'";
$res = odbc_exec($cxn, $sql);
$items = 0;
while ($row = odbc_fetch_array($res))
{
$items++;
}
odbc_free_result($res);
echo "<br>total No. of rows: $items";
?>