So what I am trying to produce is something like this:

Except, I do not want duplicates, when there is more than one sign, it becomes duplicated as well as re creating the “C” list view header. My SQL query is creating a column known as first_char which is holding the first character of one of the other columns…….below is my code:
<?php foreach ($data as $name=>$signs): ?>
<!-- If name is not empty, create the header -->
<?php if (isset($name) && !empty($signs)): ?>
<div data-role='collapsible-set' data-theme='d'>
<h2>Username: <strong id="headerName"><?=$name?></strong></h2>
<?php endif; ?>
<?php endforeach; ?>
<!-- for every sign, take the first char and create a list view -->
<?php foreach ($signs as $char):
$current_char = '';
if ($char['first_char'] != $current_char){
$current_char = $char['first_char'];
echo '<ul data-role="listview" data-dividertheme="d" style="margin-top: 0;"><li data-role="list-divider">'.$current_char.'</li></ul><br>';
}
foreach ($signs as $sign):
if($current_char == $sign['first_char'] and !empty($signs)):
?>
<div data-role='collapsible' data-collapsed='true' data-icon='arrow-l'>
<h3><?=$sign['sign_name']?></h3>
<div class='ui-grid-a'>
<div class="ui-block-a">
<div class="ui-bar ui-bar-d" style="height:25px;">
<strong>Last Seen:</strong><strong id="text"><?=$sign['last_connected']?></strong>
</div>
</div>
<div class="ui-block-a">
<div class="ui-bar ui-bar-d" style="height:25px;">
<strong>Resolution:</strong><strong id="text"><?=$sign['resolution_x'].'x'.$sign['resolution_y']?></strong>
</div>
</div>
<div class="ui-block-a">
<div class="ui-bar ui-bar-d" style="height:25px;">
<strong>Group Name:</strong><strong id="text"><?=$sign['group_name']?></strong>
</div>
</div>
<div class="ui-block-a">
<div class="ui-bar ui-bar-d" style="height:25px;">
<strong>Sign Number:</strong><strong id="text"><?=$sign['sign_id']?></strong>
</div>
</div>
</div>
</div>
<?php endif; ?>
<?php endforeach; ?>
<?php endforeach; ?>
Thanks in advance
This fixes the previous error and gets rid of the duplication. $current_char needed to be outside the foreach loop, and removed the 2nd foreach.
The query used above for SQL was this: