brooksh Posted February 11, 2008 Share Posted February 11, 2008 I am trying to sort my images by file name, but it is out of place. How can I sort it in order? This is how it sorts, how can I change it to go from 1-12? image_1.jpg image_10.jpg image_11.jpg image_12.jpg image_2.jpg image_3.jpg image_4.jpg image_5.jpg image_6.jpg image_7.jpg image_8.jpg image_9.jpg Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted February 11, 2008 Share Posted February 11, 2008 technically they are sorted by name. You are trying to sort by some integer value so you are going to need a sorting function basically you want to take that integer off the keys (maybe explode) and then sort the array based on those values Look at a sorting function Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted February 11, 2008 Share Posted February 11, 2008 You don't state where these value are, but if they are in an array - http://php.net/natsort Quote Link to comment Share on other sites More sharing options...
brooksh Posted February 11, 2008 Author Share Posted February 11, 2008 This is the sql $sql = "SELECT imagename FROM images WHERE id = '$id' order by imagename"; Quote Link to comment Share on other sites More sharing options...
revraz Posted February 11, 2008 Share Posted February 11, 2008 Use leading 0's in front of the single digits. image_01.jpg 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.