CodeIgniter Forums
DB error in view - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: DB error in view (/showthread.php?tid=7200)



DB error in view - El Forum - 03-29-2008

[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


DB error in view - El Forum - 03-29-2008

[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);
}