How to transfer value to another page with a link?

Example

Hello, I am learning using Codeigniter , can someone tell me or give an example code? what I need in Round Id, we have 111, I want to give it a link and a search database with a value of 111, how to do it? here is the code i tried but still wrong

<div class="row" id="ajaxdata">
        <table border="1">  
            <tr>
                <th>Round Id</th>
                <th>Player Id</th>
                <th>Bet Place</th>
                <th>Total Bet</th>
                <th>Win</th>
                <th>Lose</th>
            </tr>

            <?php foreach ($tbl_bet_spot as $data) {?>  
                <tr>
                    <td><a href="<?php echo site_url('account/detail_round_id?select=111');?>"><?php echo $data->round_id;?></a>
                    <td><?php echo $data->id;?></td>
                    <td><?php echo $data->bet;?></td>
                    <td><?php echo $data->total_bet;?></td>
                    <td><?php echo $data->win;?></td>
                    <td><?php echo $data->lose;?></td>
                </tr>
            <?php } ?>
            </table>
        </table>
</div>

controller

public function detail_round_id(){
        $select = $_GET['select'];

        $data['tbl_bet_spot'] = $this->login_model->selectRoundId_by_round($select)->result();

        print_r ($data);
    }

I am just trying to use my code and now it works, but it is static here

<td><a href="<?php echo site_url('account/detail_round_id?select=111');?>"><?php echo $data->round_id;?></a>

How can I send this value <?php echo $data->round_id;?>to the controller correctly ? Many thanks.

+4
source share
3 answers

Use this code

<td><a href="<?php echo site_url()?>/account/detail_round_id/<?php echo $data->round_id;?>"><?php echo $data->round_id;?></a></td>

controller

public function detail_round_id(){
        $select = $this->uri->segment(3);

        $data['tbl_bet_spot'] = $this->login_model->selectRoundId_by_round($select)->result();

        print_r ($data);
    }
+5
source

Try it, it can help you,

, ,

<td><a href="<?php echo site_url('account/detail_round_id/'.$data->round_id);?>"><?php echo $data->round_id;?></a>

,

public function detail_round_id($id){
    $data['tbl_bet_spot'] = $this->login_model->selectRoundId_by_round($id)->result();
    print_r ($data);
}
+3

, ,

  <a href="<?php echo base_url(); ?>account/detail_round_id/select/<?=$data->round_id?>"><?php echo $data->round_id;?></a>

,

 $select=$this->uri->segment(4);

,

+3
source

Source: https://habr.com/ru/post/1653989/


All Articles