I don't quite follow your description but..
PHP Code:
$result = queryMysql("SELECT Concat(firstname,' ', lastname), user FROM profiledetails ORDER BY lastname");
concatenates (joins) firstname and lastname separated by a space, which becomes the first field returned, which you refer to later as $row[0].
PHP Code:
$result = queryMysql("SELECT firstname, lastname, user FROM profiledetails ORDER BY lastname");
will keep firstname and lastname separate, referred to as $row[0] and $row[1] in your later code. Then, to perform your comparison, you would use:
PHP Code:
if ($row[0] . ' ' . $row[1] == $user) continue;
which temporarily rejoins first and lastname.
I may not have answered your precise requirement, but I'm sure the answer is in the above description