How to Sort Resource Type Like $result=mysql_query()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
abhiraj60
Forum Newbie
Posts: 1
Joined: Tue Mar 23, 2010 4:52 am

How to Sort Resource Type Like $result=mysql_query()

Post by abhiraj60 »

Can we sort a resource type in php
eg: $result=mysql_query("select * from table");

Is there any way to sort the resultset in $result instead of doing it in the query directly.
shafiq2626
Forum Commoner
Posts: 88
Joined: Wed Mar 04, 2009 1:54 am
Location: Lahore
Contact:

Re: How to Sort Resource Type Like $result=mysql_query()

Post by shafiq2626 »

Hi!
you can sort your query by Asc and Desc like

Code: Select all

mysql_query("select * from table order by date Asc or Desc")
please check it
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: How to Sort Resource Type Like $result=mysql_query()

Post by flying_circus »

abhiraj60 wrote:Can we sort a resource type in php
eg: $result=mysql_query("select * from table");

Is there any way to sort the resultset in $result instead of doing it in the query directly.
You can drop the results to an array and then sort the array. Though, you'll take a performance hit over a SQL solution.
Post Reply