view the reort in ascending order

Discussion in 'PHP' started by newphpcoder, Nov 25, 2010.

  1. newphpcoder

    newphpcoder New Member

    Joined:
    Sep 24, 2010
    Messages:
    101
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Web Programmer
    Location:
    Philippines
    Good day!
    I have a mysql_query code to sleect the date from the database and my problem is the output is not in ascending order. Here is my code:
    PHP:
     $query "SELECT plt_no FROM plt_transact WHERE plt_date BETWEEN '" $_POST["from_date"] . "' AND '" $_POST["to_date"] . "' ";
    I try this code
    PHP:
     $query "SELECT plt_no FROM plt_transact WHERE plt_date BETWEEN '" $_POST["from_date"] . "' AND '" $_POST["to_date"] . "' ORDER BY plt_no ASC ";
    But it did not work...where i can put the code for Asc.
    Thank you
     
  2. Max2010

    Max2010 New Member

    Joined:
    Oct 14, 2010
    Messages:
    17
    Likes Received:
    1
    Trophy Points:
    0
    Home Page:
    http://www.logoarena.com
    you ordered by plt_no, you should order by plt_date instead:

    PHP:
    $query "SELECT plt_no FROM plt_transact WHERE plt_date BETWEEN '" $_POST["from_date"] . "' AND '" $_POST["to_date"] . "' ORDER BY plt_date ASC;";
    I also suggest you to sanitize the POST inputs before querying a db
     
  3. newphpcoder

    newphpcoder New Member

    Joined:
    Sep 24, 2010
    Messages:
    101
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Web Programmer
    Location:
    Philippines
    Thank you
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice