Reputation: 13
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.
Upvotes: 1
Views: 32
Reputation: 534
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
Upvotes: 1