![]() |
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><?php echo $heading; ?></h2> <p><?php echo anchor('purestaff/index','Return to Home Page');?> / <?php echo anchor('purestaff/addContractor','Add New Contractor');?></p> <hr align="left" width="75%" size="2%" color="red"> <?php foreach($query->result() as $row): ?> <h3><?php echo $row->fname ?> <?php echo $row->lname?></h3> <h5><?php echo anchor('purestaff/conEdit/'.$row->id, 'Edit');?> / <?php echo anchor('purestaff/contractorDelete/'.$row->id, 'Delete');?></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); } |