thanks Jason.
that didn't work properly at all, until I changed the $j to $i like so,
<?php
$j = 0;
do {
for ($i = 0; $i < $totalRows_rslastfiveviewed; $i++){
//print_r ($_SESSION["criteria"][$i]);
if ($_SESSION["criteria"][$i] == $row_rslastfiveviewed['ItemID']) echo $row_rslastfiveviewed['ItemName'];
}
$j++;
} while ($row_rslastfiveviewed = mysql_fetch_assoc($rslastfiveviewed));
?>
but I still get the products listed in order of itemid, as in my first example above