Kamis, 14 Januari 2016

Tutorial PHP & MySQL : CRUD Part 2

Tutorial PHP & MySQL : CRUD Part 2

Hey buddy tutorial computer science previously discuss the creation of simple applications that CRUD in PHP & MySQL the first part. This time we will continue the tutorial yesterday, so I suggest you to read my previous article. In the last article we've managed to create a new database, table, database.php, create.php, and read.php. This time we will create two more php file which function to modify and delete the contents of the records in the table. Php file that we will create is update.php and delete.php.

Source code delete.php

<?php
include '/database.php';
try{
$id=isset($_GET['id'])?$_GET['id']:die('ERROR:Record ID not found.');
$query="DELETE FROM products WHERE id=?";
$stmt=$con->prepare($query);
$stmt->bindParam(1,$id);
if($stmt->execute()){
header('Location:read.php?action=deleted');
}else {
die('Unable to delete record.');
}
}
catch(PDOException $exception){
die('ERROR:'.$exception->getMessage());
}
?>

After you finish creating the php file, then run this CRUD application by typing the following address in your browser. http: //localhost/bootstrap-3/read.php if no error will appear as follows.

Tutorial PHP & MySQL : CRUD Part 2

If you click Edit, then it will look like the following

Tutorial PHP & MySQL : CRUD Part 2

If you click on delete, it will display the alert message that we have made with JavaScript

Tutorial PHP & MySQL : CRUD Part 2


For those of you who still feel confused can see the video below, and if you want to download the complete source code from start to finish could through the link I provided below.

Video Tutorial PHP & MySQL : CRUD Part 2


Download Source Code


Tutorial PHP & MySQL : CRUD Part 2 Rating: 4.5 Diposkan Oleh: Jamhari 2015

0 komentar:

Posting Komentar