Ich möchte nur meine Daten in der Datenbank mit codeigniter zeigen.Zeige Datenbankdaten mit CodeIgniter
Mein Code zeigt error 404 The page you requested was not found
.
Modell
<?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();
}
}
?>
-Controller
<?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;
}
Ansicht
<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>
Überprüfen Sie Ihre .htaccess-Datei –
haben Sie Route geschrieben? – splash58
Daftar_controller löscht 'Controller' Name. Controller-Name sollte Daftar sein. Und dann können Sie eine Verbindung zu * http: //example.com/daftar/* –