I need to order the list as follows;
Here are some part of the code;
const DEFAULT_ORDER_COLUMN = "title";
const DEFAULT_ORDER_BY = "asc";
public function category() {
$orderColumn = isset( $_GET['column'] ) && in_array($_GET['column'], $this->orderColum) ? $_GET['column'] : self::DEFAULT_ORDER_COLUMN;
$orderBy = isset( $_GET['order'] ) && in_array($_GET['order'], $this->orderBy) ? $_GET['order'] : self::DEFAULT_ORDER_BY;
$params['total'] = $search->rowCount();
$params['result'] = $search->fetchAll();
template::add_content(template::load('homepage/category', $params));
}
I tried to get this issue done with this code
if ( isset( $_GET['order_no'] ) ) != 1 {
const DEFAULT_ORDER_COLUMN = "order";
const DEFAULT_ORDER_BY = "desc";
} else {
const DEFAULT_ORDER_COLUMN = "title";
const DEFAULT_ORDER_BY = "asc";
}
but did not work. What would be the solution?
Based on your criteria, you need the following order clause:
ORDER BY `order_no` DESC, `title`
However, from your code it is not clear how you are building your sql and how the $_GET
variables are related to your question.