How can i LIMIT results within a while loop?


Take a look at the following page:

You can see a list of products and “Quicklinks” at the top of the page which takes users to the appropriate product listing.

Now, i need to a “back to top” link at the end of every set of products, so for example you can see “Aromatic”, so before “Aromatic Magnum” starts i need to add a back to top link.

Now i have had to iterate through each field to display the results, my code is shown below:

		if($brandrow['brandCount'] != 1){ 
		//start iterating   
        $saveBrand = '';
        <a name='top'></a>
	        <div id="quicklinks">
	        while($rowlinks = mysql_fetch_array($productsOne)){ 
		    echo "<li><a href='#$rowlinks[brand]'>$rowlinks[brand] &raquo;</a></li>";
			<div class="line"></div>
			<table cellspacing="0" width="100%">
	                    <th style="width: 400px; text-align:left; color:#b92923; font-weight:bold">Name</th>
	                    <th style="width: 103px; text-align:left; color:#b92923; font-weight:bold">Cost:</th>
	                    <th style="color:#b92923; font-weight:bold; text-align:left;">Country</th>
	            while($row = mysql_fetch_array($products)) {  
	                if($row['brand'] != $saveBrand) {           
		                    echo "<tr class='tdrow' style='font-size: 16px; height: 20px; line-height: 38px; border-bottom:1px solid #999'><td><a name='$row[brand]'></a> $row[brand]</td></tr>";               
		                    $cycle = false;
		                    $saveBrand = $row['brand'];   
	                echo "<tr class=\\"row$i\\"><td class='tdrow'>$row[name]</td><td class='tdrow'>&pound;$row[cost]</td><td class='tdrow'>$row[country]</td></tr>"; 
				    $i = $i % 2;  

Can you see where i need to add this?

Thanks again

Sorry the Subject/Title of this thread is rather confusing, sorry

Can a moderator please delete this thread please, i will re post as the title is wrong.