php - mysql sort data result A-Z and split each section with lines -


i have few thousands of rows in mysql table
after selecting records in ascending order want format each section of results in alphabetic order in format

a ab abc abcd abcde abcdef ------------------------------------- b bab babc babcd babcdef ------------------------------------- c ca cab cabc cabcd cabcde cabcdef ------------------------------------- 

i need demacate each of sections of alphabet lines.

in php (and other languages) strings infact arrays of characters. $string[0] hold first character of string.

<?php $rows = get_rows_from_mysql();  $section = false;  foreach ($rows $row) {    if ($section != strtolower($row['name'][0])) {     if ($section != false) echo "------------------------";     $section = strtolower($row['name'][0]);   }    echo $section['name']; } ?> 

above code not handle grouping of numbers or special characters !"#, should point.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -