• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
retrieve parameters from url and build dynamic queries

Hi everyone, I'm new with codeigniter. I have this problem. I have a western table with data and a view that shows everything. Procedural php code use when I wanted to generate an art director page I put the link followed by? :

director? id_regista = $ id_regista

then I went to the landing page and filled in the select with the recovery in GET. But here on codeigniter it doesn't work! I've tried several model-like things:


Details VIEW:

                  echo "<h5><a href='index.php/western/regista/$id_regista/'>.$row->regia</a></h5>";

Details MODEL:

function regista()


    $id_regista= $this->uri->segment(3);
    $query  = $this->db->select('*')
      ->where('id_regista', '$id_regista') // Condition
    return $query->result();



VIEW:    echo "<h5><a href='index.php/western/regista?id_regista=$id_regista'>.$row->regia</a></h5>";


  function regista1()


    echo $this->input->get('$id_regista');

    $query = $this->db->query("SELECT * FROM western where 'id_regista' = '$id_regista'");

    if ($query->num_rows() == 0) {

      show_error('empty db!');
    } else {

      return $query->result();

but both solutions do not dynamically generate the corresponding director for me starting from the home director link.

How do I retrieve the parameter and fill the query to build the page since

    $id_regista = $_GET['id_regista'];

put in model don't work?

For either solution A or B use in the Western controller

    function regista()

                $data['result'] = $this->western_model->regista();
                $this->load->view('regista_view', $data);

and I also bothered to insert in the index


thanks in advance on some helpful tips to solve, I have tried everything but I can't solve the parameter capture problem either using GET or segment    

Is this for CI3 or 4?
Look at the tutorial for a simple example:
For CI4: http://codeigniter.com/user_guide/tutori...ction.html
For CI3: http://codeigniter.com/userguide3/tutori...ction.html

Don't get the id from the model, add a parameter $id_regista to your controller. Something like that:

PHP Code:
public function regista ($id_regista NULL)
    // Then call your model and pass it $id_regista as a parameter

CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.