how to insert,edit,delete in same page using php

What have you tried so far? Plus we would need database structure, information about what needs to be inserted, deleted and edited...

Here is a simple class that uses mysql to get you started. This was just showing you an example.. you would need to sanitize the data and do some validation checking.

class Crud {

    public function edit($data = array(), $row_id)
    {
        $query = mysql_query("UPDATE `table_name` SET field_name='{$data['value']}', field_name='{$data['value']}', field_name='{$data['value']}' WHERE id='$row_id'");
        if(!query) die("Failed to update query").mysql();

        $query = mysql_affected_rows();

        if($query == 1){
            return true;
        }else{
            return false;
        }
    }


    public function insert()
    {
        $query = mysql_query("INSERT INTO `table_name` (`field_name`, `field_name`) VALUES('{$data['value']}','{$data['value']}')");

        $query = mysql_affected_rows();

        if($query == 1){
            return true;
        }else{
            return false;
        }

    }

}


$crud = new crud();

$edit = $crud->edit(array('field_name' => 'value', 'field_name' => 'value', 'field_name' => 'value'), 100);

if($edit == true){
    echo 'successful edit';
}else{
    echo 'Failed edit';
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.