Try changing:
<?php } while ($row_chapters = mysql_fetch_assoc($chapters)); ?>
to:
<?php $RepeatSelectionCounter_1++; ?>
<?php } while ($row_chapters = mysql_fetch_assoc($chapters)); ?>
If that doesn't work, i'll start a private ticket to get more information from you.