Hi All, I'm trying to display results across 3 cells - for example: #5 Perle Cotton 223 | 225 | 301 304 | 326 | 333 #12 Perle Cotton 211 | 223 | 224 225 | 356 | #4 Braid 95 | 100HL | 102 Right NOW it is displaying like: #5 Perle Cotton 223 | 225 301 | 304| 326 #12 Perle Cotton 211 | 223 224 | 225| 356 #4 Braid 95 | 100HL 102 This is the code I am working with: $z =0; while ($thread = db_fetch($tresult)) { // if z is divisible by 3 echo ($z %3 == 0) ? '<tr>' : ''; if ($thread_type != $thread['type']) { echo "<td colspan=\"3\">{$thread[type]}</td>\n"; while($z++ %3 !==0) { // if not enough tds - add empty tds until end of tr echo '<td> </td>'; } // everytime we get here - we have just filled a tr with tds, // so start new tr and output type, then start another new tr echo '</tr><tr><td colspan="3"> type </td></tr><tr>'; $thread_type = $thread[type]; } echo '<td> '.$thread[colourID].' </td>'; // end the tr on every third cycle echo (++$z %3 == 0) ? '</tr>' : ''; } The HTML looks like: <tr> </tr> <tr> <td colspan="3"> #5 Perle Cotton </td> </tr> <tr> <td> 223 </td> <td> 225 </td> </tr> <tr> <td> 301 </td> <td> 304 </td> <td> 326 </td> </tr> <tr> <td> 333 </td> <td> </td> <td> </td> </tr> <tr> <td colspan="3"> #12 Perle Cotton </td> </tr> <tr> <td> 211 </td> <td> 223 </td> </tr> <tr> <td> 224 </td> <td> 225 </td> <td> 356 </td> </tr> <tr> </tr> <tr> <td colspan="3"> #4 Braid </td> </tr> <tr> <td> 95 </td> <td> 100HL </td> </tr> <tr> <td> 102 </td> can ANYONE see where I have gone wrong? Any guidance is appreciated. Thanks! Aaron