DrTrans Posted May 4, 2012 Share Posted May 4, 2012 so I'm running a query on a database to get address's $address = $row['address']; it returns "1234 Test St" I want to be able to sort all the records by the street name without the numbers Quote Link to comment https://forums.phpfreaks.com/topic/262070-filter-data/ Share on other sites More sharing options...
DrTrans Posted May 4, 2012 Author Share Posted May 4, 2012 query = "SELECT * FROM props WHERE loginid = '$loginid' AND active = '$active' ORDER BY address ASC "; basically i want it to see what "address " and sort it by the second word ASC. Quote Link to comment https://forums.phpfreaks.com/topic/262070-filter-data/#findComment-1343027 Share on other sites More sharing options...
xyph Posted May 4, 2012 Share Posted May 4, 2012 You'll want to store it in it's own column. You COULD sort by first filtering the numbers out of the data, then sorting by that, but that's extremely inefficient. Quote Link to comment https://forums.phpfreaks.com/topic/262070-filter-data/#findComment-1343054 Share on other sites More sharing options...
TFT2012 Posted May 4, 2012 Share Posted May 4, 2012 I think you probably need seperate the "street" columns to like "street No." and "street Name". When you grab the both columns from database, you can perform array_multisort, like array_multisort($streetNo, SORT_DESC, $streetName, SORT_DESC); Quote Link to comment https://forums.phpfreaks.com/topic/262070-filter-data/#findComment-1343123 Share on other sites More sharing options...
xyph Posted May 4, 2012 Share Posted May 4, 2012 Sort using SQL. SELECT whatever FROM table ORDER BY streetName, streetNumber Quote Link to comment https://forums.phpfreaks.com/topic/262070-filter-data/#findComment-1343166 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.