PHP – CRUD Islemler Serisi 5
- Sevdanur GENC

- May 20, 2015
- 1 min read
Bir onceki PHP – CRUD Islemler Serisi 4 yazisinda view customer paneli uzerinde bulunan listenin hemen yan tarafindaki edit butonunun aktiflestirilmesi icin gerekli php komutlarindan bahsetmistik. Son olarak bu yazimizda ise, view customer paneli uzerindeki delete butonunun aktiflestirilmesi icin gerekli php komutlarindan bahsediyor olucaz.
Bunun icin delete_customer.php ve delete_record.php dosyalariyla ilgili komutlari asagida inceleyebilirsiniz;

delete_customer.php
<?PHP echo "you are on the delete_customer.php <br/>"; $id = $_GET<'id'>
; mysql_connect("localhost","root","") or die ("could not connect the server"); mysql_select_db("d_base") or die ("could not connect the database"); $sql = "select * from customer where id = $id"; $result = mysql_query($sql); $row = mysql_fetch_array($result); echo "<h3> + your are about to delete the below record + </h3>"; echo "id : <b>".$row<'id'>
."</b><br/>"; echo "firstname : <b>".$row<'firstname'>
."</b><br/>"; echo "lastname : <b>".$row<'lastname'>
."</b><br/>"; echo "address : <b>".$row<'address'>
."</b><br/>"; echo "email : <b>".$row<'email'>
."</b><br/>"; echo "<br/>are you sure you want to delete the record"; echo "<a href=\"delete_record.php?id=".$row<'id'>
."\">+ yes +</a>";
echo "<a href=\"index.php\">+ no +</a>";
mysql_close();
?>
delete_record.php
<?PHP $id = $_GET<'id'>
; echo "you are on the delete_customer.php and delete record no: ".$id; mysql_connect("localhost","root","") or die ("could not connect the server"); mysql_select_db("d_base") or die ("could not connect the database"); $sql = "delete from customer where id=$id"; $result = mysql_query($sql); mysql_close(); header("Location:index.php"); ?> Goruldugu gibi bir kaydin veritabanindan php komutlari yardimiyla nasil silinebilecegi hakkinda ornegimiz uzerinde kucuk bir uygulama yapmis olduk. Bu yazi serisi ile sizlere; 1. Xampp'in nasil kurulacagi ve konfigurasyon edilecegi, 2. MysSql ortami icin phpmyadmin uzerinde nasil bir veri tabani olusturulabilecegi, 3. Php dosyalarinizi localhost'ta nasil saklayabileceginiz, 4. Php dosyalarinizi nasil olusturabileceginiz, 5. Php dilinde CRUD islemlerini nasil gerceklestirebileceginiz hakkinda bilgiler vermis olduk. Keyifli calismalar dilerim.




Comments