PHP – Veri Tabanındaki Verileri Kullanarak Not Ekleme

Bu program ile veri tabanımızda yer alan öğrencilere yine veri tabanımızda yer alan öğretmen ve ders adlarını ekliyoruz. İlk olarak ekrana veri tabanımızdaki kişileri listeliyoruz, ardından düzenle butonuna basılınca seçili olan kişinin ders düzenleme ekranı kerşımıza geliyor. Burada 6 ders üzerinden düzenleme işlemleri yaptık. Kodlar aşagıdaki gibidir. Diğer öğrenci ekleme ve öğretmen ekleme dosyaları ekde yer alamktadır . Veri tabanımızın adı ogrenci ‘dir. Mysql dosyasını yüklerken bu doğrultuda yükleyiniz.

Buradan indire bilirsiniz.Kod Dosyaları

Program Kodları Dosya adı ders_ekle.php :


< ?php

require_once("mysql.php");

if (empty($_GET&#91;'dersinsert'&#93;)){

$query="SELECT * from ogrenci";
$result=$dba->query($query);
?>

<table align="center">

< ?php
while($row=$dba->fetch_assoc($result)){

$adi=$row['adi'];
$soyadi=$row['soyadi'];
$id=$row['id'];
?>
<tr>
<td>< ?=$adi?></td>
<td>< ?=$soyadi?></td>
<td><a href="ders_ekle.php?dersinsert=<?=$id?>">Dersleri Düzenle</a></td>
</tr>
< ?php
}

?>
</table>
< ?
}else if (isset($_GET&#91;'dersinsert'&#93;)){
$id=$_GET&#91;'dersinsert'&#93;;

$query="SELECT * from ogrenci where id='$id' ";
$result=$dba->query($query);
$row=$dba->fetch_assoc($result);
$adi=$row['adi'];
$soyadi=$row['soyadi'];

if (empty($_POST['kaydet'])){
?>
<form method="post" action="ders_ekle.php?dersinsert=<?=$id?>">
<table align="center" >
<tr>
<td>Öðrenci Adi</td>
<td>:</td>
<td>< ?=$adi?></td>
</tr>
<tr>
<td>Öðrenci Soyadi</td>
<td>:</td>
<td>< ?=$soyadi?></td>
</tr>
<tr>
<td>Ders 1</td>
<td>:</td>
<td>
<select name="ders1" id="1">
< ?php            $query="SELECT * from ogretmen";
$result=$dba->query($query);
while($row=$dba->fetch_assoc($result)){

$ders=$row['ders'];
$ders1=$ders;
?>
<option>< ?=$ders1?></option>
< ?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Ders 1 Öðretmeni</td>
<td>:</td>
<td>
<select name="ogrtadi1" id="11">
< ?php            $query="SELECT * from ogretmen";
$result=$dba->query($query);
while($row=$dba->fetch_assoc($result)){

$adi=$row['adi'];
$soyadi=$row['soyadi'];
$ogrtadi1=$adi.$soyadi;
?>
<option>< ?=$ogrtadi1?></option>
< ?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Ders 1 Notu</td>
<td>:</td>
<td><input type="text" name="not1"/></td>
</tr>
<tr>
<td>Ders 2</td>
<td>:</td>
<td>
<select name="ders2" id="2">
< ?php            $query="SELECT * from ogretmen";
$result=$dba->query($query);
while($row=$dba->fetch_assoc($result)){

$ders=$row['ders'];
$ders2=$ders;
?>
<option>< ?=$ders2?></option>
< ?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Ders 2 Öðretmeni</td>
<td>:</td>
<td>
<select name="ogretmen2" id="21">
< ?php            $query="SELECT * from ogretmen";
$result=$dba->query($query);
while($row=$dba->fetch_assoc($result)){

$adi=$row['adi'];
$soyadi=$row['soyadi'];
$ogretmen2=$adi.$soyadi;
?>
<option>< ?=$ogretmen2?></option>
< ?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Ders 2 Notu</td>
<td>:</td>
<td><input type="text" name="not2"/></td>
</tr>
<tr>
<td>Ders 3</td>
<td>:</td>
<td>
<select name="ders3" id="select">
< ?php            $query="SELECT * from ogretmen";
$result=$dba->query($query);
while($row=$dba->fetch_assoc($result)){

$ders=$row['ders'];
$ders3=$ders;
?>
<option>< ?=$ders3?></option>
< ?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Ders 3 Öðretmeni</td>
<td>:</td>
<td>
<select name="ogrtadi3" id="select">
< ?php            $query="SELECT * from ogretmen";
$result=$dba->query($query);
while($row=$dba->fetch_assoc($result)){

$adi=$row['adi'];
$soyadi=$row['soyadi'];
$ogrtadi3=$adi.$soyadi;
?>
<option>< ?=$ogrtadi3?></option>
< ?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Ders 3 Notu</td>
<td>:</td>
<td><input type="text" name="not3"/></td>
</tr>

<tr>
<td>Ders 4</td>
<td>:</td>
<td>
<select name="ders4" id="4">
< ?php            $query="SELECT * from ogretmen";
$result=$dba->query($query);
while($row=$dba->fetch_assoc($result)){

$ders=$row['ders'];
$ders4=$ders;
?>
<option>< ?=$ders4?></option>
< ?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Ders 4 Öðretmeni</td>
<td>:</td>
<td>
<select name="ogrtadi4" id="select">
< ?php            $query="SELECT * from ogretmen";
$result=$dba->query($query);
while($row=$dba->fetch_assoc($result)){

$adi=$row['adi'];
$soyadi=$row['soyadi'];
$ogrtadi4=$adi.$soyadi;
?>
<option>< ?=$ogrtadi4?></option>
< ?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Ders 4 Notu</td>
<td>:</td>
<td><input type="text" name="not4"/></td>
</tr>
<tr>
<td>Ders 5</td>
<td>:</td>
<td>
<select name="ders5" id="select">
< ?php            $query="SELECT * from ogretmen";
$result=$dba->query($query);
while($row=$dba->fetch_assoc($result)){

$ders=$row['ders'];
$ders5=$ders;
?>
<option>< ?=$ders5?></option>
< ?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Ders 5 Öðretmeni</td>
<td>:</td>
<td>
<select name="ogrtadi5" id="select">
< ?php            $query="SELECT * from ogretmen";
$result=$dba->query($query);
while($row=$dba->fetch_assoc($result)){

$adi=$row['adi'];
$soyadi=$row['soyadi'];
$ogrtadi5=$adi.$soyadi;
?>
<option>< ?=$ogrtadi5?></option>
< ?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Ders 5 Notu</td>
<td>:</td>
<td><input type="text" name="not5"/></td>
</tr>
<tr>
<td>Ders 6</td>
<td>:</td>
<td>
<select name="ders6" id="select">
< ?php            $query="SELECT * from ogretmen";
$result=$dba->query($query);
while($row=$dba->fetch_assoc($result)){

$ders=$row['ders'];
$ders6=$ders;
?>
<option v>< ?=$ders6?></option>
< ?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Ders 6 Öðretmeni</td>
<td>:</td>
<td>
<select name="ogrtadi6" id="select">
< ?php            $query="SELECT * from ogretmen";
$result=$dba->query($query);
while($row=$dba->fetch_assoc($result)){

$adi=$row['adi'];
$soyadi=$row['soyadi'];
$ogrtadi6=$adi.$soyadi;
?>
<option>< ?=$ogrtadi6?></option>
< ?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Ders 6 Notu</td>
<td>:</td>
<td><input type="text" name="not6"/></td>
</tr>
<tr>
<td colspan="4" align="center"><input type="submit" name="kaydet" value="Kaydet"/></td>
</tr>
</table>
</form>
< ?php
}else if (isset($_POST&#91;'kaydet'&#93;)){
$ders1=$_POST&#91;'ders1'&#93;;
$ogrtadi1=$_POST&#91;'ogrtadi1'&#93;;
$not1=$_POST&#91;'not1'&#93;;

$ders2=$_POST&#91;'ders2'&#93;;
$ogretmen2=$_POST&#91;'ogretmen2'&#93;;
$not2=$_POST&#91;'not2'&#93;;

$ders3=$_POST&#91;'ders3'&#93;;
$ogrtadi3=$_POST&#91;'ogrtadi3'&#93;;
$not3=$_POST&#91;'not3'&#93;;

$ders4=$_POST&#91;'ders4'&#93;;
$ogrtadi4=$_POST&#91;'ogrtadi4'&#93;;
$not4=$_POST&#91;'not4'&#93;;

$ders5=$_POST&#91;'ders5'&#93;;
$ogrtadi5=$_POST&#91;'ogrtadi5'&#93;;
$not5=$_POST&#91;'not5'&#93;;

$ders6=$_POST&#91;'ders6'&#93;;
$ogrtadi6=$_POST&#91;'ogrtadi6'&#93;;
$not6=$_POST&#91;'not6'&#93;;

$q="UPDATE ogrenci set d1='$ders1', n1='$not1', o1='$ogrtadi1',d2='$ders2', n2='$not2', o2='$ogretmen2', d3='ders3', n3='$not3', o3='$ogrtadi3', d4='ders4', n4='$not4', o4='$ogrtadi4', d5='ders5', n5='$not5', o5='$ogrtadi5', d6='ders6', n6='$not6', o6='$ogrtadi6' where id='$id' ";
$res=$dba->query($q);

echo "<center><a href='ders_ekle.php'>Geri Dön</a></center>";
}

}
?>

One thought on “PHP – Veri Tabanındaki Verileri Kullanarak Not Ekleme

  • Hocam merhaba, konuyu hortlamış olacam ama bu kodlar elinizde varsa tekrar ekleyebilir misiniz?
    Teşekkürler

Bir Cevap Yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir