Postingan lainnya
[ask] Codeigniter masih newbie
misi kalo kesalahanya yg kaya gini yang salah mananya sih model, controller, view, apa route-nya ... mohon bimbingannya terima kasih
//ROUTE defined('BASEPATH') OR exit('No direct script access allowed'); $news = ['news']; $route['default_controller'] = 'welcome/gambar'; $route['(:any)'] = 'welcome/gambar/$1';
$route['404_override'] = ''; $route['translate_uri_dashes'] = FALSE;
//CONTROLLER nama filenya News.php defined('BASEPATH') OR exit('No direct script access allowed');
class News extends CI_Controller {
public function __construct() { parent::__construct(); $this->load->model('berita_model'); $this->load->helper('url_helper'); }
public function index() { $data['isi'] = $this->load->berita_model->tampil_berita(); $data['judul'] = 'Arsip Berita'; $this->load->view('portal_berita/index', $data); }
}
// MODEL nama filenya Berita_model.php class Hots extends CI_Model {
public function __construct() { $this->load->database(); }
public function tampil_berita() { $query = $this->db->get('news'); return $query->result_array(); }
}
//VIEWSnya foreach($isi as $row) { echo "
" .$row['title']. "
"; echo "
" .$row['text']. "
"; }
3 Jawaban:
Jawaban Terpilih
Waaah gan itu alamat URL nya kurang bagus kayaknya kalo masalah kayak gini cuba agan lihat deh video tutorial Codeigniter di sini, ada kayaknya t
ane ga bisa liat gambarnya gan , itu yang agan panggil link apa?
nama class agan News . tapi rout nya di setting pake 'welcome' . sesuaikan sama class yang mau di arahin gan .
oke gan ane coba ulang lagi, Makasih gan sebelumnnya