title: Display data from database using codeigniter
body: <p>Hi im new to codeigniter and i stuck in displaying data from database. I have tried to find solution but yet can't understand them properly. So can anyone help me with this? really need your expert suggestions thankyou!!</p>
  
  <p>View file Userinsert_view.php</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Insert Data Into Database Using CodeIgniter Form&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;div id="container"&gt;
  &lt;?php echo form_open('Userinsert_controller'); ?&gt;
  &lt;h1&gt;Insert Data Into Database Using CodeIgniter&lt;/h1&gt;&lt;hr/&gt;
  &lt;?php if (isset($message)) { ?&gt;
  &lt;CENTER&gt;&lt;h3 style="color:green;"&gt;Data inserted successfully&lt;/h3&gt;&lt;/CENTER&gt;&lt;br&gt;
  &lt;?php } ?&gt;
  &lt;?php echo form_label('Student Name :'); ?&gt; &lt;?php echo form_error('dname'); ?&gt;&lt;br /&gt;
  &lt;?php echo form_input(array('id' =&gt; 'dname', 'name' =&gt; 'dname')); ?&gt;&lt;br /&gt;
  
  &lt;?php echo form_label('Student Email :'); ?&gt; &lt;?php echo form_error('demail'); ?&gt;&lt;br /&gt;
  &lt;?php echo form_input(array('id' =&gt; 'demail', 'name' =&gt; 'demail')); ?&gt;&lt;br /&gt;
  
  &lt;?php echo form_label('Student Mobile No. :'); ?&gt; &lt;?php echo form_error('dmobile'); ?&gt;&lt;br /&gt;
  &lt;?php echo form_input(array('id' =&gt; 'dmobile', 'name' =&gt; 'dmobile', 'placeholder' =&gt; '10 Digit Mobile No.')); ?&gt;&lt;br /&gt;
  
  &lt;?php echo form_label('Student Address :'); ?&gt; &lt;?php echo form_error('daddress'); ?&gt;&lt;br /&gt;
  &lt;?php echo form_input(array('id' =&gt; 'daddress', 'name' =&gt; 'daddress')); ?&gt;&lt;br /&gt;
  
  &lt;?php echo form_submit(array('id' =&gt; 'submit', 'value' =&gt; 'Submit')); ?&gt;
  &lt;?php echo form_close(); ?&gt;&lt;br/&gt;
  &lt;div id="fugo"&gt;
  
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Controller file</p>
  
  <p>Userinsert_controller.php</p>
  
  <pre><code>  &lt;?php
  
  class Userinsert_controller extends CI_Controller {
  
  function __construct() {
  parent::__construct();
  $this-&gt;load-&gt;model('Userinsert_model');
  }
  function index() {
  //Including validation library
  $this-&gt;load-&gt;library('form_validation');
  
  $this-&gt;form_validation-&gt;set_error_delimiters('&lt;div class="error"&gt;', '&lt;/div&gt;');
  
  //Validating Name Field
  $this-&gt;form_validation-&gt;set_rules('dname', 'Username', 'required|min_length[5]|max_length[15]');
  
  //Validating Email Field
  $this-&gt;form_validation-&gt;set_rules('demail', 'Email', 'required|valid_email');
  
  //Validating Mobile no. Field
  $this-&gt;form_validation-&gt;set_rules('dmobile', 'Mobile No.', 'required|regex_match[/^[0-9]{10}$/]');
  
  //Validating Address Field
  $this-&gt;form_validation-&gt;set_rules('daddress', 'Address', 'required|min_length[10]|max_length[50]');
  
  if ($this-&gt;form_validation-&gt;run() == FALSE) {
  $this-&gt;load-&gt;view('Userinsert_view');
  } else {
  //Setting values for tabel columns
  $data = array(
  'Student_Name' =&gt; $this-&gt;input-&gt;post('dname'),
  'Student_Email' =&gt; $this-&gt;input-&gt;post('demail'),
  'Student_Mobile' =&gt; $this-&gt;input-&gt;post('dmobile'),
  'Student_Address' =&gt; $this-&gt;input-&gt;post('daddress')
  );
  //Transfering data to Model
  $this-&gt;Userinsert_model-&gt;form_insert($data);
  $data['message'] = 'Data Inserted Successfully';
  //Loading View
  $this-&gt;load-&gt;view('Userinsert_view', $data);
  }
  }
  </code></pre>
  
  <p>Model file</p>
  
  <p>Userinsert_model.php</p>
  
  <pre><code>&lt;?php
  class Userinsert_model extends CI_Model{
  function __construct() {
  parent::__construct();
  }
  function form_insert($data){
  // Inserting in Table(students) of Database(college)
  $this-&gt;db-&gt;insert('students', $data);
  }
  }
  ?&gt;
  </code></pre>