Welcome Guest, Not a member yet? Register   Sign In
DB error in view
#1

[eluser]justmelat[/eluser]
What am I doing wrong?

Here is my controller:
function contractors()
{
$data['title']="PureStaff-Contractors";
$data['heading']="Active Contractors View";
$data['query']=$this->db->get('contractors');
$where = "active='Yes'";
$data['query']=$this->db->where($where);

$this->load->view('contractors_view.php', $data);
}
Here is part of the view:
<h2>&lt;?php echo $heading; ?&gt;</h2>
<p>&lt;?php echo anchor('purestaff/index','Return to Home Page');?&gt; /
&lt;?php echo anchor('purestaff/addContractor','Add New Contractor');?&gt;</p>
<hr align="left" width="75%" size="2%" color="red">

<?php foreach($query->result() as $row): ?&gt;

<h3>&lt;?php echo $row->fname ?&gt; &lt;?php echo $row->lname?&gt;</h3>

<h5>&lt;?php echo anchor('purestaff/conEdit/'.$row->id, 'Edit');?&gt; / &lt;?php echo anchor('purestaff/contractorDelete/'.$row->id, 'Delete');?&gt;</h5>

I get this error:
Fatal error: Call to undefined method CI_DB_mysql_driver::result() in C:\EasyPHP20b1\www\ci\system\application\views\contractors_view.php on line 13

Line 13 is the line above in red
#2

[eluser]justmelat[/eluser]
Never mind, I figured it out. For those who run in to the same problem the where here is my solution:

function contractors()
{
$data['title']="PureStaff-Contractors";
$data['heading']="Active Contractors View";
$where = "active='Yes'";
$data['query']=$this->db->get_where('contractors',$where);

$this->load->view('contractors_view.php', $data);
}




Theme © iAndrew 2016 - Forum software by © MyBB