If you have trouble with php code look for an example within vBulletin or other scripts, here is an example of a proper switch statement, you can find it in memberlist.php in vBulletin 3.0.3
PHP Code:
switch ($sortfield)
{
case 'username':
$sqlsort = 'user.username';
break;
case 'joindate':
$sqlsort = 'user.joindate';
break;
case 'posts':
$sqlsort = 'user.posts';
break;
case 'lastvisit':
$sqlsort = 'lastvisittime';
break;
case 'reputation':
$sqlsort = iif($show['reputationcol'], 'reputationscore', 'user.username');
$secondarysortsql = ', user.username';
break;
default:
$sqlsort = 'user.username';
$sortfield = 'username';
}