champoi Posted November 16, 2008 Share Posted November 16, 2008 i'm trying to get values from my mysql and sort it before showing it in the page, but i just cant get the hang of it, this is my code: $listsql = "SELECT * FROM `users_db` WHERE `user_level`='11'"; $listqry = mysql_query($listsql) or die(mysql_error()); $list = mysql_fetch_assoc($listqry); foreach ($list as $key => $row) { $comp_name[$key] = $row['comp_name']; } array_multisort($comp_name, SORT_ASC, $list); i just want to sort one set of array (the comp_name) and let the other values along the sorted array to be displayed, but i dont know where it's stored and i get problems when using the while() when displaying the values, does anyone have a better option than this? or im doing things incorrectly? HELP! ??? Link to comment https://forums.phpfreaks.com/topic/132935-solved-array_multisort-help/ Share on other sites More sharing options...
gevans Posted November 16, 2008 Share Posted November 16, 2008 I think I know what you're trying to do, try the code bellow in place of yours. You can sort your results in the mysql_query; $listsql = "SELECT comp_name FROM `users_db` WHERE `user_level`='11' ORDER BY comp_name ASC"; $listqry = mysql_query($listsql) or die(mysql_error()); while($list = mysql_fetch_array($listqry)){ echo $list['comp_name'].'<br />'; } Link to comment https://forums.phpfreaks.com/topic/132935-solved-array_multisort-help/#findComment-691315 Share on other sites More sharing options...
champoi Posted November 16, 2008 Author Share Posted November 16, 2008 wow, thnx! haha, been stuck in this for sometime, now my problem is that other values in the table are not appearing oh well, i'll try to fix it somehow ) Link to comment https://forums.phpfreaks.com/topic/132935-solved-array_multisort-help/#findComment-691325 Share on other sites More sharing options...
gevans Posted November 16, 2008 Share Posted November 16, 2008 That would be me over tidying other peoples code; "SELECT comp_name FROM was "SELECT * FROM Link to comment https://forums.phpfreaks.com/topic/132935-solved-array_multisort-help/#findComment-691326 Share on other sites More sharing options...
champoi Posted November 16, 2008 Author Share Posted November 16, 2008 ohhhhhhhhhhh, hahaha! it's already 1230AM in my country and i havent really got enough sleep ever since i started making this site ) thnx very much! Link to comment https://forums.phpfreaks.com/topic/132935-solved-array_multisort-help/#findComment-691342 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.