RE: [PHP-DB] Two Column Sort

From: Date: Thu, 04 Mar 2004 10:55:20 +0000
Subject: RE: [PHP-DB] Two Column Sort
Groups: php.db 
Request: Send a blank email to php-db+get-33284@lists.php.net to get a copy of this message
On 03 March 2004 17:07, kc68@cornell.edu wrote: > I'm re-raising an issue I never quite resolved which has become more > critical. I want to sort a table on two columns. There are > about 440 > rows of which about 400 are blank in the first sort column (CBC); the > other rows show B in that column. When I use the coding > below, the two > column sort takes place but the rows designated B are at the > bottom of the > (long) table and I want them at the top. Neither asc nor desc > accomplishes this (just reverses the second factor order, > still at the > bottom below the blanks). > > Here's the php code for the sort command: > > echo "<td><div align='center'><font > size='3'><b>CBC <a > href='contributions22504.php?sort_field=cbc, > net_receipts&sort_order=desc' > target='_self'><font > size='2'>Sort</a></b></font></div></td>\n"; > > Here's the basic setup that begins the script: > > # get sort order (if any) passed to script > $sort_field = $_REQUEST['sort_field']; > if (! $sort_field) {$sort_field = "State";} > $sort_order = $_REQUEST['sort_order']; > if (! $sort_order) {$sort_order = "asc";} Well, your going to need an order phrase that looks like this: ORDER BY CBC DESC, NET_RECEIPTS ASC so you may need a little rethink about how you're passing those arguments. Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@leedsmet.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.db (#33284) next »