[eluser]Unknown[/eluser]
Hello codeigniter community, I am going through some of the examples in the documentation and when I output my database content it only outputs the word Array. I am using codeigniter with XAMPP. Also I am new to all these technologies so it is possible that I could have made a mistake creating my database or made a mistake anywhere else. Here is the code:
Code:
<?php
class Blog extends Controller {
function Blog(){
parent::Controller();
$this->load->model('Blogmodel');
}
function index()
{
$data['title'] = "My Real Title";
$data['heading'] = "My Real Heading";
//$data['insert'] = $this->Blogmodel->insert_entry();
$data['query'] = $this->Blogmodel->get_entries();
$this->load->view('blogview', $data);
}
}
?>
Code:
?php
class Blogmodel extends Model {
var $name = '';
var $section = '';
function Blogmodel()
{
// Call the Model constructor
parent::Model();
$this->load->database();
}
function get_entries()
{
$query = $this->db->get('links');
if($query->num_rows()>0){
// return result set as an associative array
return $query->result_array();
}
}
function insert_entry()
{
$data = array(
'url' => 'My title' ,
'name' => 'My Name' ,
'section' => 'My date'
);
$this->db->insert('links', $data);
}
function update_entry()
{
$this->title = $_POST['title'];
$this->content = $_POST['content'];
$this->date = time();
$this->db->update('entries', $this, array('id' => $_POST['id']));
}
}
?>
Code:
<html>
<head>
<title><?php echo $title;?></title>
</head>
<body>
<h1><?php echo $heading;?></h1>
<h2><?php echo $query;?></h2>
</body>
</html>
Here are my database settings:
Code:
INSERT INTO `montage`.`links` (`name`, `url`, `section`) VALUES ('Jimmy', 'blablabla', 'home');
Thank you for your time :-)