Porkie Posted June 17, 2009 Share Posted June 17, 2009 i want to display my results from my database query above the alphabet line , how would i do that ? I want it in accending name order also , any help please? at the moment it displays it below the alphabet line ? $alpha = range('A','Z'); function linkify(&$letter) { $letter = "<a href='?l={$letter}'>{$letter}</a>"; } array_walk($alpha,'linkify'); $alpha = implode(' - ',$alpha); echo $alpha; $search = (in_array(strtolower($_GET['l']),range('a','z')))? $_GET['l'] : 'A'; $sql = mysql_query("SELECT * FROM Bands WHERE bandname LIKE '{$search}%'"); while($row = mysql_fetch_array($sql)) { echo "<br />"; echo $row['bandname']; echo "<br />"; } mysql_close($con); ?> EDITED BY akitchin: please use code tags in future posts. Quote Link to comment https://forums.phpfreaks.com/topic/162568-displaying-results/ Share on other sites More sharing options...
RussellReal Posted June 17, 2009 Share Posted June 17, 2009 +echo the $alpha variable AFTER you output what you want to output on the top of it lol.. echo $alpha; put that after the loop Quote Link to comment https://forums.phpfreaks.com/topic/162568-displaying-results/#findComment-858007 Share on other sites More sharing options...
Porkie Posted June 17, 2009 Author Share Posted June 17, 2009 i dont get you sorry expalin im new to this , probably very simple lol cheers Quote Link to comment https://forums.phpfreaks.com/topic/162568-displaying-results/#findComment-858016 Share on other sites More sharing options...
RussellReal Posted June 17, 2009 Share Posted June 17, 2009 you said you want what you looped to show ABOVE the alphabet line.. so move echo $alpha; UNDER the loop... oh and to make your sql order in the right order, just add ORDER BY bandname ASC Quote Link to comment https://forums.phpfreaks.com/topic/162568-displaying-results/#findComment-858041 Share on other sites More sharing options...
Porkie Posted June 17, 2009 Author Share Posted June 17, 2009 yeh lol that was very strupid i kicked myself after haha , mind just went blank :/ where would i put the ASC part? cheers for help mate Quote Link to comment https://forums.phpfreaks.com/topic/162568-displaying-results/#findComment-858049 Share on other sites More sharing options...
RussellReal Posted June 17, 2009 Share Posted June 17, 2009 $sql = mysql_query("SELECT * FROM Bands WHERE bandname LIKE '{$search}%' ORDER BY bandname ASC"); Quote Link to comment https://forums.phpfreaks.com/topic/162568-displaying-results/#findComment-858056 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.