tripper Posted February 13, 2007 Share Posted February 13, 2007 Hello, im using php to manipulate data in mysql and output it onto a site. I want to sort out two rows in a table like example: D X F X A O B X E O C O into something like this A O C O E O B X D X F X (so you notice that all the names corresponing to 'O' are sorted out ..same with 'X') Any ideas? Thanks Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 13, 2007 Share Posted February 13, 2007 check out the array sorting functions php. http://us3.php.net/array_multisort Without seeing how the data is stored we can't help much. Quote Link to comment Share on other sites More sharing options...
tripper Posted February 13, 2007 Author Share Posted February 13, 2007 the data is stored pretty much like in the example..except the letters A,B,C correspond to the names and O,X is as it is. There are a few more columns in the table, but im only looking at these two. Iam not sure what you mean by how it is stored. Its just a table with a bunch of columns in Mysql. And Im using php, to ouput that table to a site. I can manage everything else, its just the sorting. First I have to sort out the 'O' and the 'X's then, sort the names within the 'O's and sort the name within the 'X's Thanks Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 13, 2007 Share Posted February 13, 2007 Do you know how to get data out of MySQL into PHP? If not, go read some of the tutorials in the beginner's section. If so, add this to your query: " ORDER BY (xoname) DESC, (abcname) DESC," Quote Link to comment Share on other sites More sharing options...
tripper Posted February 13, 2007 Author Share Posted February 13, 2007 Oh thanks. Yea i had been doing some searching on it, but didnt know if you could use the order thing twice in your query statement. None of the tutorials have this specific exmaple. But Thanks alot Cheers Quote Link to comment 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.