Welcome Guest, Not a member yet? Register   Sign In
database driven application using code igniter framework
#1

[eluser]subhashramesh[/eluser]
Hi all,
I am new to code igniter framework and i tried INTRODUCTION TO CODEIGNITER PHP FRAMEWORK PART2-databses,which is in
http://www.devshed.com/c/a/PHP/Building-...Framework/ and i am unable to run application
by using url as https://localhost/CodeIgniter_1.7.1/index.php/Users
gtting error as
404 PAGE NOT FOUND.
in models folder i put file as Users.php as follows
class Users extends Model{

function Users(){
parent::Model();
$this->load->database();
}

function getAllUsers(){
$query=$this->db->get('sample');
if($query->num_rows()>0){
return $query->result_array();
}
}
function getUsersWhere($field,$param){
$this->db->where($field,$param);
$query=$this->db->get('sample');
return $query->result_array();
}
function getNumUsers(){
return $this->db->count_all('sample');
}
}
in controllers folder i put file Users.php as follows
class Users extends Controller{

function Users (){
parent::Controller();
$this->load->model('Users');
}
function index(){
$data['users']=$this->Users->getUsers();
$data['numusers']=$this->Users->getNumUsers();
$data['title']='Displaying user data';
$data['header']='User List';
$this->load->view('users_view',$data);
}
}
In views folder i put file as users_view.php as follows.
<html>

<head>

<title><?php echo $title;?></title>

</head>

<body>

<h1>&lt;?php echo $header;?&gt;</h1>

<ul>

&lt;?php foreach($users as $user):?&gt;

<li>

<p>&lt;?php echo $user['a'].' '.$user['b'].$user['c'];?&gt;</p>

</li>

&lt;?php endforeach;?&gt;

</ul>

<p>&lt;?php echo 'Total number of users :'.$numusers;?&gt;</p>

&lt;/body&gt;

&lt;/html&gt;
in above sample is table in efo databse with 3 columas a,b,c respectively.

could you please help to solve above problem.


Messages In This Thread
database driven application using code igniter framework - by El Forum - 08-27-2009, 12:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB