1

I am working on a user database for a Clan. I am really inexperienced with PHP and MySQL. The database selects users from a MySQL Table. The users have a nickname and a user_status.

The first version I wrote ordered the Users as followed:

$sql = $sql . " ORDER BY user_status, nickname ASC";

So now the clan Leaders wish that the active Members show up first on that list. The problem with that is that there are user_status such as "abgelehnt" which means user refused in German.

And that's where the Trouble starts. "abgelehnt" shows up higher than "aktiv".

I am really thankful for any suggestions.

1

1 Answer 1

1

You can try this one

$sql = " SELECT filed1, field2, field3 FROM tablename
ORDER BY FIELD(status, "active", "inactive", "canceled")";

Change name of priority values according yours

Sign up to request clarification or add additional context in comments.

1 Comment

Thank u so much. That was exactly the Reference I needed!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.