Transfer Variable by Href

Asked

Viewed 45 times

0

I’m doing a query system wanted to transfer a variable per href, I do a query by "status" OPEN or CLOSED after this inform only the ID not to get too much information on the screen, and needed to create a href for another page view expanding the registration. Follow my Cod to better understand, if anyone has a hint thank you.

Controller:

    $palavra = $this->input->post("palavra");
    $usercadastro = $this->model_c->consultar($palavra);


    if ($usercadastro->num_rows() == 1) {
        $dados['consulta'] = $this->model_c->consultarnc();
        $this->load->view('ConsultaCadastro_v', $dados);

    }elseif ($usercadastro->num_rows() == 0) {
        $dados['consulta'] = $this->model_c->consultarnc02();
        $this->load->view('ConsultaCadastro_v', $dados);
    }

}

View:

<h1>RNCS</h1>
<hr />
<?php foreach ($consulta as $cadastro) : ?>
<p><strong>Bairro:</strong> <a  class="font-weight-bold" ><?php echo $cadastro->bairro ?></p></a>
<p><strong>Nome:</strong> <a  class="font-weight-bold" ><?php echo $cadastro->nome ?></p></a>
<p><strong>complemento:</strong> <a  class="font-weight-bold" ><?php echo $cadastro->complemento ?></p></a>
<hr />
<?php endforeach; ?>

1 answer

1


You need to send by HREF the id? if it is this at the time of mounting the page puts at the end of HREF

?NOMEDAVAR=ID

So you will have access to the php’s GET variable, using $GET['NOMEDAVAR'] then you can mount the other page based on this var that will be the ID.

<a  class="font-weight-bold" href = "pagina.php?NOMEDAVAR=ID">
  • Thank you Lucas!

Browser other questions tagged

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