[eluser]cupidleomanoj[/eluser]
thanks for your reply, I have tried something with CI, but i cant get the output. can you please help me. the following are the codes.
model:- (file name : Helloworld_model.php)
<?php
class Helloworld_model extends CI_Model {
public function __construct() {
parent::__construct();
}
function getData() {
$query=$this->db->get('data');
if($query->num_rows() > 0) {
}
else {
return $query->result();
}
}
}
?>
controller:- (filename : helloworld.php)
<?php
class Helloworld extends CI_Controller {
public function __construct() {
parent::__construct();
// Your own constructor code
}
function index() {
$this->load->model('helloworld_model');
$data['result'] = $this->helloworld_model->getData();
$data['page_title'] = "CI";
$this->load->view('helloworld_view',$data);
}
}
?>
view:- (filename : helloworld_view.php)
<html>
<head>
<title><?=$page_title?></title>
</head>
<body>
<?php foreach($result as $row):?>
<h3><?=$row->title?></h3>
<p><?=$row->text?></p>
<br />
<?php endforeach;?>
</body>
</html>
----------------------------------------------
I get error as
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: views/helloworld_view.php
Line Number: 6
-------------------------------------------------