[Help Req]: MySQL Fetch Problem

I have written a db function in my lib as

function RunSQL($sql)
{
    define('BASEPATH','TEMP');
    include "../../../config/database.php";

    /* Connect to the database */
    $link = mysql_connect($db['dbname']['hostname'], $db['dbuser']['username'], $db['pwd']['password']);
    if (!$link) {
        die('Could not connect: ' . mysql_error());
    }
    mysql_select_db($db['db']['database']) or die(mysql_error());

    $result = mysql_query($sql);
    while($row = mysql_fetch_assoc($result)){
        $dataset[] = $row;
    }

    return $dataset;
}

Then in my class, I call this function and try to go through records as:

        $rs_transactions = RunSQL($sql);
        print_r($rs_transactions);

        foreach($rs_transactions as $row)
        {
            echo "<br><br>...in loop....";
        }

Problem is that print_r shows there r three records returned, but in foreach loop, it goes through only for first record. It doesn’t loop for all three records.

What could be wrong?

Show us the result of print_r($rs_transactions)

If it is an array with 3 entries, then the foreach loop would print 3 times.

Thanks, it is working now. I was doing something wrong in the loop (a condition) that was causing it to break after one iteration.