[eluser]asmaa kamal[/eluser]
hi
i coded this
controller::
Code:
<?php
class Test extends CI_Controller{
function alldata()
{
$config['hostname'] = "localhost";
$config['username'] = "root";
$config['password'] = "";
$config['database'] = "test";
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;
$this->load->model('model',$config);
$mydata['result']=$this->model->get_last_ten_entries('users');
$this->load->view('blogview',$mydata);
}
}
?>
in model :::
Code:
<?php
class Model extends CI_Model {
var $title = '';
var $content = '';
var $date = '';
function __construct()
{
// Call the Model constructor
parent::__construct();
}
function get_last_ten_entries()
{
$query = $this->db->get('entries',1);
return $query->result();
}
function insert_entry()
{
$this->title = $_POST['title']; // please read the below note
$this->content = $_POST['content'];
$this->date = time();
$this->db->insert('entries', $this);
}
function update_entry()
{
$this->title = $_POST['title'];
$this->content = $_POST['content'];
$this->date = time();
$this->db->update('entries', $this, array('id' => $_POST['id']));
}
}?>
in view :::
Code:
<html>
<head>
<title>
</head>
<body>
<ul><?php foreach($result as $item) :?>
<li><?php echo $item->FirstName ;?> </li>
<?php endforeach ;?>
</ul>
</body>
</html>
the database attached in this topic
_______
i got this errors::
A PHP Error was encountered
Severity: Notice
Message: Array to string conversion
Filename: core/Loader.php
Line Number: 270
**************************
A PHP Error was encountered
Severity: Notice
Message: Array to string conversion
Filename: core/Loader.php
Line Number: 303
**************************
A Database Error Occurred
Error Number: 1046
No database selected
SELECT * FROM (`entries`) LIMIT 1
Filename: C:\wamp\www\t\system\database\DB_driver.php
Line Number: 330
****************************
plz help me!