yep, i just think you are going about it the wrong way. try this
$var = "";
$i=0;
while($row = mysql_fetch_array($res)) {
if($i == 1 || $i == 3) {
$var = 'foo';
} else {
$var = '';
}
echo "id: ".$res['id']." var: ".$var ;
$i++;
}
Edit : The first response is a better option as you are actually defining your search before the loop and can search it easier than with multiple if/elses like I have given you as an example. Both work though, just his is more efficient.
Edit2: LOL, our code is almost exactly the same lol. cracks me up when my solution mirrors someone else's =) shows we are on the same path at least.