6. Data Delete

obviously have to put this code in fresh.php. where have your database connect.

/* Data Delete */
    public function Delete($table,$id){
        $query = mysqli_query($this->connect,"DELETE FROM $table WHERE id=$id");
            return true;
        } else{
            return false;


if (isset($_REQUEST['id'])) {
    /* The isset () used to check whether a variable is set or not.
       If a variable is already unset.The isset() return false.
    //super global variable $_REQUEST uses to collect the value of the input field:
    if ($obj->Delete("members", $_REQUEST['id'])) {
        $err_msg = "Successfully Deleted";
    } else {
        $err_msg = "No Data Delete";

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Show Database</title>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">

        <div style="width: 800px; margin: 0 auto">
            echo (isset($err_msg)) ? $err_msg : "";
            <table class="table table-bordered table-hover" style="text-align: center;">
                $team = $obj->getData("members");
                foreach ($team as $single) {
                        <td><?php echo $id; ?></td>
                        <td><?php echo $name; ?></td>
                        <td><?php echo $email; ?></td>
                        <td><?php echo $phone; ?></td>
                        <td><?php echo $address; ?></td>
                        <td><a href="edit.php?id=<?php echo $id; ?>" class="btn btn-primary"><span class="glyphicon glyphicon-pencil"></span></a>&nbsp;<a href="tabulize_data.php?id=<?php echo $id; ?>" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span></a></td>
                <td colspan="6" align="right"><a class="btn btn-info" href="insert.php">Add New Member</a></td>

Output following screenshot:


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s