Will this sort ascending if clicked once and descending if clicked second time? (PHP)?

Spazz

New member
switch ($sort) {
case 'name':
if($order_by == "name ASC"){
$order_by = 'name DESC';
}else{
$order_by = 'name ASC';
}
break;
(More not included)

If I read this logically it should run through and say first time its going to sort it ascending (its defaulted) if I click it again it should run through and the IF statement should be true therefore switches the sorting to descending?

What is a better or different way to sort ascending and descending per click (click once ascending, click a second time descending)?
 
Back
Top