<?php
$ogrenciler = [
(object) [
'numara' => '1',
'isim' => 'Ali',
'not' => 90,
],
(object) [
'numara' => '2',
'isim' => 'Berat',
'not' => 40,
],
(object) [
'numara' => '3',
'isim' => 'Berke',
'not' => 50,
],
(object) [
'numara' => '4',
'isim' => 'Emre',
'not' => 30,
],
];
if (isset($_POST["submit"])) {
$aranan_numara = $_POST["numara"];
$ogrenci = null;
foreach ($ogrenciler as $o) {
if ($o->numara == $aranan_numara) {
$ogrenci = $o;
break;
}
}
if ($ogrenci != null) {
echo "Öğrenci adı: " . $ogrenci->isim . "<br>";
echo "Öğrenci numarası: " . $ogrenci->numara . "<br>";
echo "Öğrenci notu: " . $ogrenci->not . "<br>";
} else {
echo "Öğrenci bulunamadı.";
}
}
?>
<form method="POST">
<caption>Öğrenci Paneli</caption>
<br>
<input type="text" style="width: 220px" placeholder="Öğrencinin numarasını giriniz." name="numara" id="numara">
<br>
<input type="submit" name="submit" value="Öğrenciyi Ara">
</form>