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.. Quote 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? Quote 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')"; ?> Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.