Welcome Guest, Not a member yet? Register   Sign In
help in getting and displaying info from database
#1

[eluser]kalelgwapo[/eluser]
i already know how to input data into my database but i just couldnt get it to display the info. I'm stuck in reading the user_guide and i dont know what to do, here's my codes from my view, model and controller.

from the controller (i tried to test and input the $username if it will display in the views, but it doesnt)
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Profilepage extends CI_Controller {

    function __construct()
    {
        parent::__construct();
    }

    function index()
    {
        $username = $this->input->post('username');
        $this->load->model('Profile');
        $this->Profile->getinfo($username);
        $this->load->view('profile');
    }
}

from the views
Code:
<form name="form1" method="post" action="">
<div>
    <div align="center"><a href="profilepic"><img src="CI doesnt allow me to post links" width="120" height="120" alt="Photo Here" /></a></div>
  </div>
  &lt;?php echo $username?&gt;
  <div><p>Name:&lt;?php echo $firstname?&gt; &lt;?php echo $lastname?&gt;</p>
  <p>Email Address:&lt;?php echo $email?&gt;</p>
  <p>Birthdate:&lt;?php echo $bday?&gt;</p>
  <p>Messages</a></p>
  <p>Friends</a></p></div>
&lt;/form&gt;

and from the model
Code:
&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


class Profile extends CI_Model {

    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }
    
    function getinfo($username)
    {
      $dsn = 'CI doesnt allow me to post links';
      $this->load->database($dsn);        
      $query = $this->db->query("select username from users");
      return $firstname = $query->row();
    }

}

?&gt;

im fairly a beginner in CI and doesnt understand it much, i hope you can help me


Messages In This Thread
help in getting and displaying info from database - by El Forum - 05-23-2011, 06:19 AM
help in getting and displaying info from database - by El Forum - 05-23-2011, 07:58 AM
help in getting and displaying info from database - by El Forum - 05-23-2011, 08:04 AM
help in getting and displaying info from database - by El Forum - 05-23-2011, 08:25 AM
help in getting and displaying info from database - by El Forum - 05-23-2011, 08:31 AM
help in getting and displaying info from database - by El Forum - 05-23-2011, 08:32 AM
help in getting and displaying info from database - by El Forum - 05-23-2011, 08:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB