php while() how to stop after three times?
===

I'm trying to make a PHP photo gallery (yes, I've tried other solutions, none work with the setup I want) and I am trying to make this while loop stop after three times, because I want to show three thumbnails per table row. Here's my current code:

    <table>
    <tr>
    <?php while($row2 = mysql_fetch_assoc($result)) { echo "
    <td><a href='URL/".$row2['file']."'><img src='URL/".$row2['file']."' width='200' height='106' /></a></td>
    "; } ?>
    </tr>
    </table>

I don't remember learning anything about stopping PHP loops, so please help! It'd be greatly appreciated :)