简体   繁体   中英

print echo json_encode values in php from modal dialog

public function book_update()
{
    $data = array(
        'book_isbn' => $this->input->post('book_isbn'),
        'book_title' => $this->input->post('book_title'),
        'book_author' => $this->input->post('book_author'),
        'book_category' => $this->input->post('book_category'),
    );
    $this->book_model->book_update(array('book_id' => $this->input->post('book_id')), $data);
    echo json_encode(array("status" => TRUE));
}

i want two parameter based on this output thats why

In Model

public function book_update(....)
{
    $data = array(
        ...
    );

    $this->db->where('id', $id);

    if (!$this->db->update('mytable', $data))
        return false;
    else
        return true;

}

In Controller

$result = $this->book_model->book_update(array('book_id' => $this->input->post('book_id')), $data);
echo json_encode(array("status" => $result));

In Html

You will get TRUE of FALSE based on update success/fail.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM