How to select a value from the least

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • simon2x1
    New Member
    • Dec 2008
    • 123

    #1

    How to select a value from the least

    the code below will diplay the following:

    1 john
    2 dave
    3 mark

    i want it to start from the least like this

    3 mark
    2 dave
    1 john

    Code:
    $result = mysql_query("SELECT * FROM users") or die(mysql_error());
    $count = 0;
    while ($line = mysql_fetch_array($result, MYSQL_ASSOC)){
    				
    $num = $line[id];
    $person = $line[user];
    				
    echo "$num $person";
    	$count++;
    	}
  • JKing
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    Use an order by clause in your query.

    Code:
    $result = mysql_query("SELECT * FROM users ORDER BY id DESC") or die(mysql_error());

    Comment

    Working...