switch ($sortfield) { case 'title': case 'lastpost': case 'replycount': case 'views': case 'postusername': case 'voteavg': break; default: $sortfield='lastpost'; }