- Yang harus dilakukan adalah
- Download codeigniter
- Download grocerycrud
- Extract codeigniter dan grocerycrud
- Copy and replace semua isi dari grocerycrud ke dalam codeigniter
- Simpan folder codeigniter di directory xampp\htdocs
- Buat sebuah database di localhost/phpMyAdmin dengan nama table files_db
- Atur konfigurasi database di codeigniter (\application\config\database.php)
- Rubah username menjadi "root" dan database menjadi "files_db"
- Buat sebuah controllers baru di \application\controllers dengan nama main.php
- isi main.php dengan :
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Main extends CI_Controller {
function __construct()
{
parent::__construct();
/* Standard Libraries of codeigniter are required */
$this->load->database();
$this->load->helper('url');
/* ------------------ */
$this->load->library('grocery_CRUD');
}
public function index()
{
echo "<h1>Welcome to the world of Codeigniter</h1>";//Just an example to ensure that we get into the function
die();
}
public function files()
{
$db_multimedia = new grocery_CRUD();
$db_multimedia->set_table('tb_file');
$output = $db_multimedia->render();
$this->_example_output($output);
}
function _example_output($output = null)
{
$this->load->view('v_main.php',$output);
}
}
- Buat view di directory \application\views dengan nama v_main.php
- isi v_main.php dengan :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<?php
foreach($css_files as $file): ?>
<link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; ?>
<?php foreach($js_files as $file): ?>
<script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>
<style type='text/css'>
body
{
font-family: Arial;
font-size: 14px;
}
a {
color: blue;
text-decoration: none;
font-size: 14px;
}
a:hover
{
text-decoration: underline;
}
</style>
</head>
<body>
<!-- Beginning header -->
<!-- End of header-->
<div style='height:20px;'></div>
<div>
<?php echo $output; ?>
</div>
<!-- Beginning footer -->
<div>Footer</div>
<!-- End of Footer -->
</body>
</html>
No comments:
Post a Comment