CodeIgniterを使用して、ユーザーがビュー内をクリックしてデータベース内のレコードの詳細を表示できるリンクを作成しようとしています。
C#を使用したASP.NET MVC3では、@Html.ActionLink("Controller", "Action", new { id = item.Id})
これは私のセッションコントローラーのindex()関数です
public function index()
{
$data['sessions'] = $this->session_model->get_sessions();
$this->load->view('_header');
$this->load->view('session/index', $data);
$this->load->view('_footer');
}
これは、リンクをクリックしてenter()関数に移動できるようにするためにロードするインデックスビューです。
<table>
<th>Session Name</th>
<th>Description</th>
<th>Host</th>
<th></th>
<?php foreach ($sessions as $session_item): ?>
<tr>
<td> <?php echo $session_item['sessionName'] ?> </td>
<td> <?php echo $session_item['sessionDesc'] ?> </td>
<td> <?php echo $session_item['adminName'] ?> </td>
<td> <a id="enterSession" href=<?php echo site_url("session/enter" + $session_item['id']) ?> >Enter</a></td>
</tr>
<?php endforeach ?>
Enterセッションは、URL "http://192.168.1.36/index.php/1"(アイテムのIDが1の場合)を指しますが、 "http://192.168.1.36/index.php/session / enter / 1 "
セッションコントローラ(以下に表示)でもenter()関数を呼び出す方法に関するアイデア
public function enter($id) {
$this->load->view('_header');
$this->load->view('session/enter');
$this->load->view('_footer');
}