Multiple checkboxes with Different label in Loop
<pre><code>&lt;?php
    $r=mysql_query("SELECT city.id as city_id, locality.id,locality.area_name  ".
                   "FROM city, locality  ".
                   "WHERE city.id = locality .city_id order by city_id"); 

    while($rss=mysql_fetch_object($r))
    {
?&gt;
&lt;legend&gt;&lt;?=$rss-&gt;city_id?&gt;&lt;/legend&gt;
&lt;input type="checkbox" name="sub_type[]" id="sub_type" value="&lt;?=$rss-&gt;id?&gt;" /&gt;
&lt;span&gt;&lt;?=$rss-&gt;area_name?&gt;&lt;/span&gt;&lt;br/&gt;
&lt;?php
    }
?&gt;
</code></pre>

<p>I am displaying area names with their city ID as a label. The problem is that this ID label is added for each area name due to the surrounding while loop. How can I prevent the ID label from being repeated multiple times, so that the checkboxes are grouped under the city ID they belong to?</p>
