Welcome Guest, Not a member yet? Register   Sign In
How to select all or get all the data in a table?
#1

[eluser]towki[/eluser]
I couldnt figure out waht wrong with my code, what i wanted is to display all the rows in a table but instead it displays only one row, only the latest data added to the database was being displayed.

This if my function in my controller(criminal.php)
Code:
public function viewRecords(){
$this->load->model('dbOperations');
$data['results']=$this->dbOperations->view_records();

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

}
This i for my model(dbOperations.php):
Code:
public function view_records()
{
$query = $this->db->query("SELECT * FROM inputtest");
if ($query->num_rows() > 0){
return $query->result_array();
}
else{

echo "EMPTY!";
}

}

And for my view(view_data.php):
Code:
<h2>Criminal Records System</h2>

&lt;?php foreach ($results as $row) ?&gt;
<h2>&lt;?php echo $row['id'] ?&gt;</h2>
<h3>&lt;?php echo $row['Name'] ?&gt;</h3>

Pls anyone help me to clear this out. Im basically new to php and codeIgniter :-)


Messages In This Thread
How to select all or get all the data in a table? - by El Forum - 07-15-2012, 07:56 AM
How to select all or get all the data in a table? - by El Forum - 07-15-2012, 08:11 AM
How to select all or get all the data in a table? - by El Forum - 07-15-2012, 08:16 AM
How to select all or get all the data in a table? - by El Forum - 07-15-2012, 08:39 AM
How to select all or get all the data in a table? - by El Forum - 07-15-2012, 08:43 AM
How to select all or get all the data in a table? - by El Forum - 07-15-2012, 09:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB