WEB PHP ordering Comand

Discussion in 'OT Technology' started by Flaxer, Dec 6, 2007.

  1. Flaxer

    Flaxer New Member

    Joined:
    Dec 7, 2006
    Messages:
    43
    Likes Received:
    0
    Alright I made some forms and am displaying the info. I want to order them by DESC I just don't know the correct command. I tried to google it and it just didn't work for me. Was wondering if anyone could help me
    Code:
    <?
    include("dbinfogg.php");
    mysql_connect($dbhost,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT * FROM news";
    $result=mysql_query($query);
    
    $num=mysql_numrows($result); 
    
    
    mysql_close();
    ?>
    
    <//---//TOP TABLE CODE\\--\\>
    
    <?
    $i=0;
    while ($i < $num) {
    $subject=mysql_result($result,$i,"subject");
    $date=mysql_result($result,$i,"date");
    $author=mysql_result($result,$i,"author");
    $body=mysql_result($result,$i,"body");
    $getnews=mysql_result($result,$i,"id");
    ?>
    
    <//--//DISPLAY CODE\\--\\>
    
    ^-- My Code
    http://www.sokillmma.com/news01.php
    ^-- The Actual Page

    Thanks in advanced!
     
  2. Nakon

    Nakon Guest

    in your SQL query, edit it to be "SELECT * FROM news ORDER BY fieldyouwanttoorderby DESC"
     
  3. Flaxer

    Flaxer New Member

    Joined:
    Dec 7, 2006
    Messages:
    43
    Likes Received:
    0
    :bowdown::bowdown:
    AWESOME!!!

    it worked

    Code:
    $query="SELECT * FROM news ORDER BY id DESC";
     

Share This Page