SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
-
Jul 2, 2009, 09:50 #1
- Join Date
- Apr 2004
- Location
- Boston
- Posts
- 482
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
sorting table rows according to one value
Hello,
Is there an easy way to sort all rows associated with a query by the value of one of the rows? Sort of like ranking.
for example:
PHP Code:<?php
$f[1] = 'text 1';
$f[2] = 'text 2';
$f[3] = 'text 3';
$val[1] = '6';
$val[2] = '1';
$val[3] = '25';
?>
Thanks.
-
Jul 2, 2009, 09:55 #2
- Join Date
- Jul 2009
- Location
- Austria
- Posts
- 43
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
A MySQL-query?
=> SELECT ... ORDER BY col
You can order ASC or DESC
See mysql-homepage order-by-optimization
-
Jul 2, 2009, 09:56 #3
- Join Date
- Oct 2008
- Posts
- 295
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Have you tried asort() or arsort() ? This if you sort in php.. else what blubb said.
-
Jul 2, 2009, 09:57 #4
- Join Date
- Apr 2004
- Location
- Boston
- Posts
- 482
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Jul 2, 2009, 11:56 #5
- Join Date
- Jun 2008
- Posts
- 39
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
so, you want to display "text 1 appeared 6 times" for example?
-
Jul 2, 2009, 12:41 #6
- Join Date
- Apr 2004
- Location
- Boston
- Posts
- 482
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Jul 2, 2009, 13:24 #7
- Join Date
- Jul 2008
- Posts
- 5,757
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
see usort()
Bookmarks