Snooble Posted March 1, 2007 Share Posted March 1, 2007 if (isset($_GET['orderby'])) { $order = $_GET['orderby']; $query = "SELECT * FROM songs ORDER BY $order"; } $query = "SELECT * FROM songs"; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); That should be all the code you need. So i put URL or : www.wezzsmusic.ifastnet.com/WM/music.php?orderby=Title and they dont change. Have a look at that page and see what you can do... You'll need to login. user = test pass = abc123 Thanks, SNooble Quote Link to comment https://forums.phpfreaks.com/topic/40707-order-by-problem-should-be-easy/ Share on other sites More sharing options...
MadTechie Posted March 1, 2007 Share Posted March 1, 2007 Just getting a ton of adverts no login !! Quote Link to comment https://forums.phpfreaks.com/topic/40707-order-by-problem-should-be-easy/#findComment-197025 Share on other sites More sharing options...
Snooble Posted March 1, 2007 Author Share Posted March 1, 2007 wezzsmusic.ifastnet.com/WM/music.php Apologies... Quote Link to comment https://forums.phpfreaks.com/topic/40707-order-by-problem-should-be-easy/#findComment-197029 Share on other sites More sharing options...
trq Posted March 1, 2007 Share Posted March 1, 2007 Your overiding your $query variable with this line. $query = "SELECT * FROM songs"; Your code needs to be more like.... <?php if (isset($_GET['orderby'])) { $order = $_GET['orderby']; $query = "SELECT * FROM songs ORDER BY $order"; } else { $query = "SELECT * FROM songs"; } // more code. ?> Quote Link to comment https://forums.phpfreaks.com/topic/40707-order-by-problem-should-be-easy/#findComment-197033 Share on other sites More sharing options...
Snooble Posted March 1, 2007 Author Share Posted March 1, 2007 Thank you, it now changes order BUT BUT BUT! There's some errors, try it and you can see... It's not proper alpherbetical order. How can i fix that. Thank you very much for your help so far!! Snooble Quote Link to comment https://forums.phpfreaks.com/topic/40707-order-by-problem-should-be-easy/#findComment-197041 Share on other sites More sharing options...
trq Posted March 1, 2007 Share Posted March 1, 2007 Both links you have provided are useless. The first is just adverts, the second, I have no idea where to navigate to to see your issue. Just explain your output and your expected results. Quote Link to comment https://forums.phpfreaks.com/topic/40707-order-by-problem-should-be-easy/#findComment-197050 Share on other sites More sharing options...
MadTechie Posted March 1, 2007 Share Posted March 1, 2007 use "ORDER BY $order ASC" or "ORDER BY $order DESC" what do you mean It's not proper alpherbetical order Quote Link to comment https://forums.phpfreaks.com/topic/40707-order-by-problem-should-be-easy/#findComment-197051 Share on other sites More sharing options...
Snooble Posted March 1, 2007 Author Share Posted March 1, 2007 wezzsmusic.ifastnet.com/WM/music.php sign in with username = test password = abc123 that link works, copy and paste it. navigate to the tab "MUSIC" and then you can see my trobule. It's hard to explain. Numbers are shown like 1 10 2 29 ... But even with the song title you should have AAAAAA before Arnold ?? Snooble Quote Link to comment https://forums.phpfreaks.com/topic/40707-order-by-problem-should-be-easy/#findComment-197055 Share on other sites More sharing options...
Snooble Posted March 1, 2007 Author Share Posted March 1, 2007 <embarrassing> Changed field to int </embarrassing> Thankyou for the help!!!!!! Learn something everyday. Quote Link to comment https://forums.phpfreaks.com/topic/40707-order-by-problem-should-be-easy/#findComment-197065 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.