Hultin
Member
- Joined
- Dec 2, 2008
- Messages
- 262
- Reaction score
- 17
Hello, I've seen alot of people not properly using the MVC modell, it's there why not use it?
Here is my support list, you will have to style it yourself.
supports_model.php (Model)
Support.php (Controller)
support.php (VIEW)
Here is my support list, you will have to style it yourself.
supports_model.php (Model)
PHP:
<?php
/*
Copyright Johan Hultin
Please don't remove this copyright information
You are free to edit, change and update the following code freely.
*/
class supports_model extends model {
public function getSupport(){
require("config.php");
$this->load->database();
$sql = $this->db->query("SELECT `name`, `online`, `group_id` FROM `players` WHERE group_id >= 3");
$ret["ammount"] = $sql->num_rows;
$ret["support"] = $sql->result_array();
return $ret;
}
}
?>
PHP:
<?php
/*
Copyright Johan Hultin
Please don't remove this copyright information
You are free to edit, change and update the following code freely.
*/
class support extends Controller {
public function index(){
$this->load->model("supports_model");
$data = array();
$data["support"] = $this->supports_model->getSupport();
$this->load->view("support", $data);
}
}
?>
support.php (VIEW)
PHP:
<?php
require("config.php");
$ide = new IDE;
try { $ide->loadInjections("support"); }catch(Exception $e) { error($e->getMessage());}
$groups = array(3 => 'Tutor', 4 => 'Senior Tutor', 5 => 'Community master', 6 => 'GOD');
echo '<h1>Support list</h1><ul>';
foreach($support['support'] as $val){
if($val['online'] == true){
$online = '<span class="green">Online</span>';
} else {
$online = '<span class="red">Offline</span>';
}
echo '<li class="support-position fl">'.$groups[$val["group_id"]].'</li>
<li class="support-name fl">'.$val['name'].'</li>
<li class="support-online fl">'.$online.'</li>';
}
echo '<div class="fc"></div></ul>';
?>
Last edited by a moderator: