OR ve AND kullanımını bir araştırmalısınız. Denemedim ancak çalışacaktır
$ogrenci = $_SESSION['ogrenciad'];
$sinif =$_SESSION['ogrencisinif'];
$sorgu = $db->prepare('SELECT * FROM the_table WHERE odevogrenci = :ogrenciad OR odevogrenci = :ogrencisinif');
$sorgu->execute([ 'ogrenciad' => $ogrenci, 'ogrencisinif' => $sinif]);
$result = $sorgu->fetchAll();