$q = mysql_query("SELECT userid, username FROM users WHERE sensei = {$r['userid']}");
$students = "Students:";
$sep = 0;
if(!mysql_num_rows($q))
{
$students .= " N/A";
Of course it will return 1
Look at your query your not asking about students your asking if there is a userid with your userid result = 1