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.
#2

[eluser]verynewtothis[/eluser]
Quote:https://localhost/CodeIgniter_1.7.1/index.php/Users

Are you sure you are running an https and not http connections on your localhost?

Do you have the right settings in your config.php file (system/application/config/config.php)? open this file and check $config['base_url'] is set properly.
#3

[eluser]huzzel[/eluser]
I had many problems with this tutorials too.

Follow this tutorial
http://henrihnr.wordpress.com/2009/04/26...plication/
or download the source
http://simple-crud-application.googlecod...les/Simple CRUD Application.zip

and you get a perfect start for a database driven app.
#4

[eluser]subhashramesh[/eluser]
thanks for your reply.
i set in config.php file as $config['base_url'] = "https://127.0.0.1/CodeIgniter_1.7.1/";
in databse.php as
$active_group = "default";
$active_record = TRUE;

$db['default']['hostname'] = "localhost";
$db['default']['username'] = "root";
$db['default']['password'] = "";
$db['default']['database'] = "efo";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";
i used url as https://localhost/CodeIgniter_1.7.1/index.php/Users
i am getting error as 404 page not found.could you please solve that.
#5

[eluser]Aishwarya.M.B[/eluser]
first rename the file as ci instead of CodeIgniter_1.7.1.
u'll surely get the output....
if u hav some more doubts, you can contact me...
my id is [email protected]




Theme © iAndrew 2016 - Forum software by © MyBB