Pentolan Pentolan - 3 months ago 6
PHP Question

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.

Answer

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);
    }