Find out how many rows there are to choose from. If there are five or fewer, then your choices are fixed and you don't need any randomness.
Assume there are at least six rows then. I hope you have some unique field - which I'll refer to as uid - to select on, because you'll want to read those into an array
$sql="SELECT uid FROM mytable WHERE ...";
$res=mysql_query($sql);
$resnum=mysql_numrows($res)-1; // -1 'cos the array we're building is zero-indexed.
for($i=0;$i<=$resnum;++$i)
{
$rows[$i]=mysql_result($res,0,'uid');
}
Now we want five distinct random numbers in the range 0..$resnum:
$i=0;
srand((double)microtime()*1000000);
while($i<5)
{ $r=rand(0,$resnum);
if(!array_search($r,$randomrows))
{ $randomrownumbers[$i++]=$r;
}
}
And the query is then
"SELECT * from mytable where uid=".$rows[$randomrows[0]]." OR uid=".$rows[$randomrows[1]]." OR uid=".$rows[$randomrows[2]]." OR uid=".$rows[$randomrows[3]]." OR uid=".$rows[$randomrows[4]]