İNDEX.PHP
include("function.php");
include("tasarim/head.php");
$sinif= new sinif();
?>
$islem=$_GET["islem"];
switch ($islem) {
case 'dersler':
$sinif->dersler();
break;
case 'ogrencilistesi':
$sinif->ogrencilistesi();
break;
case 'silson':
$sinif->silson();
break;
case 'ogrencilistesi':
$sinif->ogrencilistesi();
break;
default:
# code...
break;
}
?>
include("tasarim/footer.php");
?>
FUNCTİON.PHP
try {
$db=new PDO("mysql:host=localhost;dbname=eevrak;charset=utf8",'root','12345678');
} catch (PDOException $e) {
echo $e->getMessage();
}
class sinif {
public function dersler()
{
global $db;
$s="select * from dersler";
$ss=$db->prepare($s);
$ss->execute();
echo '
Ders Adı
Sil
Güncelle
Ders Adı
Sil
Güncelle
';
while($ok=$ss->fetch(PDO::FETCH_ASSOC)):
echo'
';
endwhile;
echo'
';
}
public function ogrencilistesi()
{
global $db;
$dersid=$_POST["dersid"];
$s="select * from ogrencilistesi where dersid=$dersid";
$ss=$db->prepare($s);
$ss->execute();
while($ok=$ss->fetch(PDO::FETCH_ASSOC)):
echo $ok["ad"];
endwhile;
}
public function silson()
{
global $db;
$id=$_POST["silid"];
$s="delete from dersler where id=$id";
$ss=$db->prepare($s);
$ss->execute();
echo "silindi";
}
}
?>
OZEL.JS
$(document).ready(function() {
$(".asil").click(function(){
var deger=$(this).attr("rel");
$.ajax({
url:"index.php?islem=silson",
type:"POST",
data:{
"silid":deger
},
success:function(){
window.location.reload();
}
})
})
$(".aders").click(function(){
var deger=$(this).attr("rel");
$.ajax({
url:"index.php?islem=ogrencilistesi",
type:"POST",
data:{
"dersid":deger
}
success:function(){
$
}
})
})
} );