I’m making a contact app (with CodeIgniter and jQuery Mobile) and I’m at the point where I’m trying to insert list dividers for each grouping of names.
Example:
A
Adam Smith
Alex Smith
B
Beth Smith
Billy Smith
So far I can get names alphabetically from mysql db: http://dl.dropbox.com/u/19118763/screenshots/before.png
THE CODE
<?php
$query = $this->db->query("SELECT * FROM `CONTACTS` ORDER BY `CONTACTS`.`FIRST` ASC LIMIT 0, 100");
foreach($query->result() as $row):
?>
<li><a href="contacts/details/<?=$row->ID?>/index.php" data-rel="dialog" data-transition="slidedown"><?=$row->FIRST?> <?=$row->LAST?></a></li>
<?php endforeach; ?>
But, once I add the following code to get the first letter of each name, I get the following result: http://dl.dropbox.com/u/19118763/screenshots/after.png
SAME CODE AS ABOVE execept added this in the foreach
<li data-role='list-divider'><?php echo substr("$row->FIRST",0,1); ?></li>
Try replacing the code you linked with this:
That should do what you need.