wake Posted August 8, 2008 Share Posted August 8, 2008 I am trying to sort the results of a stored procedure, but am not having much luck. I want to be able to give sort options to the users. Any help would be greatly appreciated. I have the code below but can't seem to merge the two ideas. $data = mssql_fetch_array($result); foreach ($data as $key => $value) { $Title[$key] = $value['Title']; } array_multisort($Title, SORT_ASC, $data); while($row = mssql_fetch_array($result)) { //echo sorted results here } Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/118858-help-sorting-ms-sql-database-results/ Share on other sites More sharing options...
wake Posted August 9, 2008 Author Share Posted August 9, 2008 Maybe instead of: while($row = mssql_fetch_array($result)) { //echo sorted results here } I need to iterate through the sorted array? Still having issues with this...there has to be a way to do this other than an ORDER BY sql statement doesnt there? Link to comment https://forums.phpfreaks.com/topic/118858-help-sorting-ms-sql-database-results/#findComment-612367 Share on other sites More sharing options...
lynxus Posted August 9, 2008 Share Posted August 9, 2008 Cant you do it in the Sql query? For instance in MySQL you can do summat like " SELECT foo FROM bar ORDER BY something desc; " I suppose you can then give users a drop down box that sends the php script a var that you can use to build your query? Ie: if dropdown box = 1 the $blaa = " query type 1 " ? Link to comment https://forums.phpfreaks.com/topic/118858-help-sorting-ms-sql-database-results/#findComment-612391 Share on other sites More sharing options...
wake Posted August 9, 2008 Author Share Posted August 9, 2008 The results are fetched from a stored procedure, and I need to sort the results differently based on a category selected. Not sure how to append an ORDER BY statement to a stored procedure, maybe this is possible? Any other ideas? Thanks for the input. Link to comment https://forums.phpfreaks.com/topic/118858-help-sorting-ms-sql-database-results/#findComment-612405 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.