Re: Am I usort-ing correctly?

From: Date: Thu, 01 Jan 1970 00:00:00 +0000
Subject: Re: Am I usort-ing correctly?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-2626@lists.php.net to get a copy of this message
you can use the following at the end: ORDER BY CoEmps, Co limit 0,100 and then in next page query ORDER BY CoEmps, Co limit 100,100 that might solve your problem if i understand you correctly. -- Regards, -- Masood Nasir :-) [Systems Engineer] - http://www.masood.net ;) -- One Net, Lahore, Pakistan. <http://www.one.net.pk> On Thu, 22 Jun 2000, Melissa Tonelli wrote: > Hello, all. > > I have a table that stores information on the number of employees at > approximately 300+ companies, 200 of which are companies of a certain type > (let's say retailers). I generate rankings on the fly by having my query > ORDER by #_employees DESC. This eliminates the need of having to maintain > a "ranks" field in the db, but it raises a new problem for me. > > I need to present a list of the 200 retailers alphabetically, but first > broken into two halves i.e., the biggest 100 retailers sorted alpha, the > remaining 200 retailers sorted alpha. I couldn't think of a way to do this > in MySQL -- if someone knows a way, that would be great. > > What I'm attempting instead is to run the ranking query (which I can LIMIT > to break the list in half), then usort the returned array. But I can't > make it work (wrong datatype in usort() call). I think there's something > wrong with the variable I'm using in my strcmp?? Here's the code. Any > hints/suggestions greatly appreciated (as always). > > $result = mysql_query("SELECT DISTINCT CoID, Co, FROM Cos WHERE > CoType='Retailer' ORDER BY CoEmps DESC LIMIT 100"); > > function co_sort($a,$b) { > return strcmp($result['Co']); > } > usort($result, co_sort); > > --- > mtonelli@bway.net > phone 718 728 7567 * fax 718 728 4420 > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#2626) next »