Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - PHP & MySQL: Ordering Something That's Already Ordered
  
User name:
Password:
Reply:
 

UserPost
sloat
Posts: 79/85
try something like,
"SELECT (stuff - crap) AS blah FROM table ORDER BY blah DESC"

php also has array sort functions if that doesn't work.
Elric
Posts: 527/687
How would I go about ordering something after I already ordered it when I pulled it from the DB?

For example:
$things=mysql_query("SELECT stuff,crap FROM table ORDER BY stuff DESC LIMIT 0,5);
while($thing=mysql_fetch_array($things) {
$barf=$thing[stuff]-$thing[crap];
$list.="$barf";
}


This is where I get stuck. If the 5 values for stuff are, say 100,75,66,32, and 8, and the 5 values for crap are 0,10,60,3, and 2, then after you subtract those, the new values for stuff are now 100,65,6,29, and 5. Since I initially ordered them by stuff, when I print $list to the screen, they'll show up in that order. But I want them to show up in their new descending order of 100,65,29,6, and 5.

Is there a command to do this, or will I have to code a new function to do this?
Acmlm's Board - I2 Archive - Programming - PHP & MySQL: Ordering Something That's Already Ordered


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.002 seconds.