Solution found :)
I just found the solution:
<?php if (!empty($row_Recordset1['contents2'])) echo ","; ?>
where the following field is <?php echo $row_Recordset1['contents2']; ?>
This way the comma will only show, if there is an entry in contents2. Same for all fields up to contents5.