I have to assume that $db->getRows() returns a list of the rows returned from the query. If that's the case, it's not surprising that "$row['num_bill']" is not defined.
You probably need to enumerate row returned by getRows(). I don't know what class you've used, but you probly need to do something like:
$rows = $db->getRows();
foreach ($rows as $row)
$txn_id = $row['num_bill'];