You will be better to store the post_statusid in a temp. array. Then you can make use of in_array() and a few simple if expressions.
PHP Code:
$arr = array();
// while($post...
{
// You may want to store postid as key up to you...
$arr[] = intval($post['post_statusid']);
}
// Now we do the checking:
if(in_array(7, $arr))
{
$statusid = 7;
}
elseif(in_array(4 //....
{
$statusid = 4;
}
else
{
$statusid = 8;
}
Makes the logic easier to understand.