get data with PHP + codeigniter by clicking a button

Asked

Viewed 558 times

-2

Good afternoon guys follows a doubt

I have a list as below: inserir a descrição da imagem aqui

By clicking history I am directed to this page: inserir a descrição da imagem aqui This page is showing all comments made for the customer to overcome

By clicking on new comment I am directed to this page: inserir a descrição da imagem aqui

See that on the page to add a new comment the client field must be filled.

What I would like to know is how can I make this field to be filled automatically with the customer, for example if we are viewing the customer’s feedback history overcome, by clicking on new comment the customer field is filled with the customer overcome.

  • 1

    I think this "pass-by-reference" tag is wrong. It has nothing to do with that your doubt. Reference passage applies to another context.

  • nor the tag "crud"

  • This is vague. How this client’s data is being uploaded to VIEW? How is this button loading the other page? With a FORM? With Ajax? By link?

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 receive the client code through the URL(GET), search for that client in the database, and upload the View passing that information. It goes 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 needs to look like this:

http://localhost/seusite/index.php/comentarios/novoComentario/1032

Browser other questions tagged

You are not signed in. Login or sign up in order to post.