phpSensei Posted July 30, 2007 Share Posted July 30, 2007 Here is my code thats above my <head> lol, not that way... <?php include("connection.php");?> <?php $sql="SELECT * FROM linklist"; //Linklist Contains movie titles and name $query= mysql_query($sql); ?> Then I have a table that lists all the movie names, but I want the movie names to be sorted by order from #-z... So I did this and it doesnt work <?php while ($data = mysql_fetch_assoc ($query) ){ // Here we retrieve the query from previously and make it into an array// asort($row['list_title']); // I fetch the name of the movies from the array I just created and I sort it..i think// echo $row['list_title']; } ?> Someone help me with this damn code, and how do you sort everthing? Quote Link to comment https://forums.phpfreaks.com/topic/62569-sort-by-alphabet-with/ Share on other sites More sharing options...
hitman6003 Posted July 30, 2007 Share Posted July 30, 2007 $sql="SELECT * FROM linklist ORDER BY list_title ASC"; Quote Link to comment https://forums.phpfreaks.com/topic/62569-sort-by-alphabet-with/#findComment-311419 Share on other sites More sharing options...
phpSensei Posted July 30, 2007 Author Share Posted July 30, 2007 THANKS, I knew that but I just thought it starts from one row and goes down... Does it do the same for dates? One more question lol : How would you make it so everytime a new movie is added, there is a list like this: 1.300 the movie 2.cool movie 3.something 4. 5. 6. 7. 8. And when a new movie is added, 300 goes down to number 2 and is replace with the new movie, and so on so on.... 1.new movie 2.300 3.cool movie 4.something 6. 7. 8. 9. ??? Quote Link to comment https://forums.phpfreaks.com/topic/62569-sort-by-alphabet-with/#findComment-311425 Share on other sites More sharing options...
calabiyau Posted July 30, 2007 Share Posted July 30, 2007 You wouldn't really have to do that...just when you want to display the results do ORDER BY id DESC...this will display the most recently added row first and go from there, as long as you have id as an auto_increment column Quote Link to comment https://forums.phpfreaks.com/topic/62569-sort-by-alphabet-with/#findComment-311429 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.