Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to transfer value to another page with link?

Example

Hello i'm stil learning, using Codeigniter can someone tell me, or give example code? what i need is in Round Id we have 111 i want give it link and search database with value 111 how to do that? here the code i tried but still not right

<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 just try with my code and it work now, but it's static in here

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

how i can send this value <?php echo $data->round_id;?> properly into controller? thanks a lot.

like image 444
Pentolan Avatar asked Dec 19 '22 13:12

Pentolan


2 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);
    }
like image 63
Manish sharma Avatar answered Feb 16 '23 14:02

Manish sharma


Try this may help you,

In view make link like this,

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

And in controller add parameter like this,

public function detail_round_id($id){
    $data['tbl_bet_spot'] = $this->login_model->selectRoundId_by_round($id)->result();
    print_r ($data);
}
like image 32
Keyur Chavda-kc1994 Avatar answered Feb 16 '23 16:02

Keyur Chavda-kc1994