<select><option>/if(){} problem

I’m having trouble figuring out how the select/options have to be coded. If “admin” is selected then the option indicating admin should be “selected”. If user, then user has to be selected. Both user or admin are in the db table and upon selection they would be stated in the url as ?usergroup=.

		if($fields[$td]=="usergroup"){
			echo "<select id=\\"userg\\" style=\\"width: 90px;\\" onchange=\\"window.location='".$_SERVER['PHP_SELF']."?usergroup='+document.getElementById('userg').options[selectedIndex].value;\\">\
\	<option";
			if($row[$fields[$td]]=="user" or $_GET["usergroup"]=="user"){
				echo " selected value=\\"".$row[$fields[$td]]."\\">".$row[$fields[$td]]."</option>\
\	";
				echo "<option value=\\"admin\\">admin";
			}else{
				echo " selected value=\\"".$row[$fields[$td]]."\\">".$row[$fields[$td]]."</option>\
";
				echo "<option value=\\"user\\">user";
			}
			echo "</option>\
</select>\
";
		}

ok thanks

i think you have your ifs backwards…try something like this
http://poundpipe.com/v/baaaj/select-admin-or-user

i also changed stuff to use single quotes so you dont have to escape double quotes, and output html instead of echoing it. you should also use selected=“selected” over just selected