Suggestion:
Get the number of rows in the table and then use this
for ($i=0;$i<25;$i++){
$num=rand($min_val,$num_rows);
if(!exists_in_array($array,$num)){
$array[] = $num;
}else{
$i--;
}
}
The you can run a loop and use the values in the $array as row_id in the query.
function exists_in_array($array,$val){
$found = false;
for($i=0;$i<count($array);$i++)
if($array[$i] == $val){
$found = true;
}
return $found;
}
//