Hy、私はcodeigniterで作業しており、同じページで複数の結果を取得する必要があります。私はそれをどうやってできるのか。複数のクエリを取得する方法は、コードページの同じページになります
モデル、コントローラ、ビューのコードを見てください。
モデル:
function asia(){
$this->db->distinct();
$this->db->select();
$this->db->from('travels_detail t');
$this->db->join('all_destination a','t.destination = a.destination','inner');
$this->db->where('region', 'asia');
$this->db->group_by('t.destination');
$query= $this->db->get();
return $query->result_array();
}
コントローラ:
function asia(){
$data['asia'] = $this->travel->asia();
$this->load->view('testing', $data);
}
ビュー:
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<table border="1">
<tr>
<td> Departure </td> <td> Destination </td>
<td> Airline </td> <td> Fare </td>
<td> Type </td> <td> Via </td>
</tr>
<?php foreach($asia as $row){ ?>
<?php
echo '<tr>
<td> '.$row['departure'].' </td>
<td> '.$row['destination'].' </td>
<td> '.$row['airline'].' </td>
<td> '.$row['fare'].' </td>
<td> '.$row['type'].' </td>
<td> '.$row['via'].' </td>
</tr>';
}
?>
</table>
</body>
</html>
私はテーブルの私のデータベースおよびディスプレイから大陸 "アジア" のデータを取得します。同様に私は同じページで他のデータを取得する必要があります。助けてください
で
$asia
を使用しているし、ビューで、私は別のforeachループを作っ$europe
方法を使用???例えばforeach($ europe_row as $ europe_row){} –ええ、確かに、なぜですか? – sepehr
、どのように私は複数のresult_array()をモデルで返しますか??? –