E
E
Evgeny Petrov2018-04-07 17:02:42
MySQL
Evgeny Petrov, 2018-04-07 17:02:42

Why doesn't sorting by price work?

There is a table with goods.
It is necessary to make sortings:
1. From old to new
2. From new to old
3. From cheap to expensive
4. From expensive to cheap
I did the first two sorts, but I can’t figure out something with the remaining two.
I asked a question earlier, but I was told that the easiest option is to add "ORDER BY cost" at the end of the query.
As a result: either I'm a fool and put the question wrong, or the answer was not entirely correct.
A fragment of the code for obtaining a list of goods immediately with sorting and output:
https://pastebin.com/25hUQN8B
Result on the page:
prntscr.com/j25d54
How to deal with this situation? How to implement such sorting?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2018-04-07
@borgore

sorting direction who will do?
and besides, a hole for sql injections

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question