I have php function with query I want to add different Order by ASC/DESC
depending on the form value the user selects so I had if statement inside the query line.
I tried but I get no error and no result, but if I without the if
it works.
<?php
SELECT * FROM Customers
if(!empty($registro_asc_desc)){
ORDER BY user_registered DESC,
} else if(!empty($post_asc_desc)){else {
ORDER BY postDESC,
}
?>
3
Answers
Unfortunately none of the above worked; no error but still no result! Here is my full query, I want to add the if statements on the line of the
ORDER BY
You can try this way:
I did try but did not work here example with the example mention above