JKinBlack Posted September 22, 2008 Share Posted September 22, 2008 I need to pull records (book titles) from a database and sort them alphabetically. The first time I pull them, sorted by first letter: a, b, c, d,... The next time I pull them, sorted: b, c, d, .... y, z, a The next time: c, d, e, .... y, z, a, b :-\ Thanks for the help.. Link to comment https://forums.phpfreaks.com/topic/125331-sort-results-alphabetically-rotate-starting-letter/ Share on other sites More sharing options...
Maq Posted September 22, 2008 Share Posted September 22, 2008 Check out limit. LIMIT $start, $how_many_from_start); Maybe recursively? Link to comment https://forums.phpfreaks.com/topic/125331-sort-results-alphabetically-rotate-starting-letter/#findComment-647842 Share on other sites More sharing options...
sasa Posted September 22, 2008 Share Posted September 22, 2008 look <?php $ord = range('a', 'z'); $time = 3; for ($i= 1; $i < $time; $i++) array_push($ord, array_shift($ord)); $ord = implode("','",$ord); $sql = "SELECT .... ORDER BY FIELD(LCASE(LEFT(`field_name`, 1)),'$ord')"; ?> Link to comment https://forums.phpfreaks.com/topic/125331-sort-results-alphabetically-rotate-starting-letter/#findComment-647928 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.