Jump to content

View the report in ascending order

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
newphpcoder

newphpcoder

    Programming Professional

  • Members
  • PipPipPipPipPipPip
  • 479 posts
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:


 $query = "SELECT plt_no FROM plt_transact WHERE plt_date BETWEEN '" . $_POST["from_date"] . "' AND '" . $_POST["to_date"] . "' ";


I try this code

 $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
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
it looks correct, do you get an error message, or is it not sorted correctly? what kind of field is plt_no ?
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#3
newphpcoder

newphpcoder

    Programming Professional

  • Members
  • PipPipPipPipPipPip
  • 479 posts

Orjan said:

it looks correct, do you get an error message, or is it not sorted correctly? what kind of field is plt_no ?

I don't get any error mes. plt_no is varchar

#4
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
ah, varchar, then it sorts litteraly, so it sorts 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 20. it needs to be numerical (int) to sort correctly as fas as I know.

what kind of data does plt_no contain?
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#5
newphpcoder

newphpcoder

    Programming Professional

  • Members
  • PipPipPipPipPipPip
  • 479 posts
plt_no is varchar

#6
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
yes, so you said, but can you give examples of the physical data to be stored there?
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#7
newphpcoder

newphpcoder

    Programming Professional

  • Members
  • PipPipPipPipPipPip
  • 479 posts

Orjan said:

yes, so you said, but can you give examples of the physical data to be stored there?

Thank you for your help..i resolved this issue or porblem. I'm wrong in adding code for ASC.