0
私はcodeigniterでデータベースに自分のデータを表示したいだけです。CodeIgniterでデータベースデータを表示
私のコードはerror 404 The page you requested was not found
です。
モデル
<?php
class Daftar_model extends CI_Model
{
public function __construct()
{
//connect ke database
$this->load->database();
}
public function get_pertanyaan()
{
$query = $this->db->get('pertanyaan_ts');
return $query->result_array();
}
}
?>
コントローラ
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class Daftar_controller extends CI_Controller {
public function index()
{
//echo "Hallo";
$this->load->model('administrator/pertanyaan/daftar_model');
$this->load->view('administrator/pertanyaan/daftar_view',$data);
$data["pertanyaan_ts"] = $this->daftarpertanyaan_model->get_pertanyaan;
}
ビュー
<html>
<head>
<title><?php echo $judul; ?></title>
</head>
<body>
<h1>Daftar User</h1>
<table border="1">
<thead>
<tr>
<th>Pertanyaan</th>
</tr>
</thead>
<tbody>
<?php
foreach($pertanyaan as $p){
?>
<tr>
<td><?php echo $p->pertanyaan; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</body>
</html>
あなたの.htaccessファイルを確認してください。 –
あなたは経路を書いてありますか? – splash58
Daftar_controllerは 'controller'の名前を削除します。コントローラ名はDaftarでなければなりません。 * http://example.com/daftar/* –