Welcome Guest, Not a member yet? Register   Sign In
database access by code igniter
#5

[eluser]Aishwarya.M.B[/eluser]
i've worked out on your code.....
i've edited the code.
just do the following changes...

ci/application/config/routes.php
$route['default_controller'] = "AccessDatabase";

system/application/config/database.php
$db['default']['database'] = "efo";

Controller:
AccessDatabase.php
<?php

class AccessDatabase extends Controller{

function AccessDatabase()

{

parent::Controller();

}



function index()

{

$this->load->model('AccessDatabase_model');



$data['result'] = $this->AccessDatabase_model->getData();

$data['page_title'] = "CI Hello World App!";

$this->load->view('AccessDatabase_view',$data);

}

}

?>



Model

AccessDatabase_model.php
<?php

class AccessDatabase_model extends Model {

function AccessDatabase_model()

{

parent::Model();

}

function getData()

{

$query = $this->db->get('sample');

if ($query->num_rows() < 0)

{

show_error('Database is empty!');

}

else{

return $query->result();

}

}



}

?&gt;


VIEW
AccessDatabase_view.php

&lt;html&gt;

&lt;head&gt;

&lt;title&gt;&lt;?=$page_title?&gt;&lt;/title&gt;

&lt;/head&gt;

&lt;body&gt;

&lt;?php foreach($result as $row):?&gt;



&lt;?=$row->a?&gt;





&lt;?=$row->b?&gt;

&lt;?=$row->c?&gt;





&lt;?php endforeach;?&gt;

&lt;/body&gt;

&lt;/html&gt;



this code is working....
try this.


Messages In This Thread
database access by code igniter - by El Forum - 08-28-2009, 05:27 PM
database access by code igniter - by El Forum - 08-28-2009, 06:27 PM
database access by code igniter - by El Forum - 08-29-2009, 01:44 AM
database access by code igniter - by El Forum - 08-31-2009, 05:19 AM
database access by code igniter - by El Forum - 09-01-2009, 12:46 AM
database access by code igniter - by El Forum - 09-01-2009, 09:09 AM
database access by code igniter - by El Forum - 09-05-2009, 01:16 AM
database access by code igniter - by El Forum - 09-05-2009, 03:19 AM
database access by code igniter - by El Forum - 09-05-2009, 04:43 AM
database access by code igniter - by El Forum - 09-05-2009, 05:15 AM
database access by code igniter - by El Forum - 09-12-2009, 11:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB