get data with PHP + codeigniter when clicking a button

-2

Good afternoon people are following a question

I have a list as below:

Clickinghistoryisdirectedtothispage: Thispageisshowingallthecommentsmadeforthecustomertoovercome

ByclickingonnewcommentI'mdirectedtothispage:

Notice that on the page to add a new comment the client field should be filled in.

What I would like to know is how can I make this field automatically populated with the client, for example if we are viewing the customer feedback history, when clicking on the new comment the client field is populated with the client overcome.

    
asked by anonymous 24.01.2017 / 19:10

1 answer

3

In your Controller, you probably have some code like this:

public function novoComentario() {
    $this->load->view('novo_comentario');
}

What you need to do is to receive the client code through the URL (GET), search that client in the database, and load the View passing this information. It looks something like this:

public function novoComentario($id) {
    $this->load->model("ClienteModel");

    // implemente buscarPorCodigo em ClienteModel
    $nome = $this->ClienteModel->buscarPorCodigo($id)->nome;

    $data = ["nome_cliente" => $nome];

    $this->load->view('novo_comentario', $data);
}

In your View

<input type="text" value="<?= $nome_cliente ?>" >

The "History" button link in the "Customer List" view should look like this:

http://localhost/seusite/index.php/comentarios/novoComentario/1032
    
24.01.2017 / 19:44