$query = mysql_query("SELECT LEFT(topic_a, 1) as 'first', topic_a FROM A ORDER by first ASC"); $letter=''; while ($row=mysql_fetch_array($query)) { if ($row['first'] !== $letter) { $letter=$row['first']; echo "<B>$first</b><br>"; } if ($row['first'] == $letter) { echo "$row[topic_a]<br>"; } } i have used the above and get http://www.fantasy-comps.com/a.php but hasnt actually done what I wanted... i wanted the letter above it and then in the same row, and if fills up the row the next row.... i.e. [b]A[/b] a, ab, ac, ad, ae, af ag, ah, ai, aj [b]B[/b] b b, ba, bb, bc