code is not working properly - 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: code is not working properly (/showthread.php?tid=54109) |
code is not working properly - El Forum - 08-22-2012 [eluser]Unknown[/eluser] Quote:this is my controller.php <?php class search extends CI_Controller { public function __construct() { parent::__construct(); $this->load->helper('url'); } public function index() { $this->load->model('Model_form'); $this->load->helper('form'); $data['countries'] = $this->Model_form->get_countries(); $data['bodies'] = $this->Model_form->get_bodies(); $data['query']=$this->Model_form->trksearch(); $this->Model_form->display(); $data['query1']=$this->Model_form->display(); $data['query2']=$this->Model_form->display(); $data['query']=$this->Model_form->display(); $data['base_url']=base_url(); $this->load->view('trksearch',$data); } ?> this iz my model.php <?php class Model_form extends CI_Model { function __construct() { // Call the Model constructor parent::__construct(); $this->load->database(); } public function display() { $make = $this->input->post('mkno'); $model = $this->input->post('modno'); $this->db->select('mkcmpny'); $this->db->where('mkno',$make); $query1=$this->db->get('mktruck'); return $query1->result(); $model = $this->input->post('modno'); $this->db->select('modnm'); $this->db->where('modno',$model); $query2=$this->db->get('mkmodel'); return $query2->result(); $this->db->select('id,km,rgat,bdty,eprc,desr'); $this->db->where('mk',$make); $this->db->where('md',$model); $query=$this->db->get('tbl_sel'); return $query->result(); } } ?> this is my view.php <div id="trucksearch"> <?php foreach($query1 as $rows) { $truck=$rows->mkcmpny; } foreach ($query2 as $rows) { $model=$rows->modnm;} foreach ($query as $rows) { $id=$rows->id; $km =$rows->km; $rgat=$rows->rgat; $bdty=$rows->bdty; $eprc=$rows->eprc; $descr=$rows->desr; ?> <br/> <table width="720" border="2" bordercolor="#999999" align="center"> <tr><td valign="Left" width="200" bgcolor="#E8E8E8" class="table_text1"><p align="left"> <strong>Make And Model :</strong></p></td> <td valign="Left" width="520" bgcolor="#E8E8E8" class="table_text1"><p align="left">a href="viewsaletrk.php?msg=<?php echo $id; ?>"><?php echo $make;?> <?php echo $model ;?></a></p></td><tr/> <tr><td valign="bottom" width="200" bgcolor="#E8E8E8" class="table_text1"><p align="left">strong>KM Run:</strong></td> <td valign="Left" width="520" bgcolor="#E8E8E8" class="table_text1"><p align="left"><?php echo $km ;?></p></td></tr> <tr><td valign="bottom" width="200" bgcolor="#E8E8E8" class="table_text1"><p align="left">strong>Body Type:</strong></td> <td valign="Left" width="520" bgcolor="#E8E8E8" class="table_text1"><p align="left">p align="left" style="color:#0d4c7d"><?php echo $bdty;?></p></td></tr> <tr><td valign="bottom" width="200" bgcolor="#E8E8E8" class="table_text1"><p align="left">strong>City:</strong></td> <td valign="Left" width="520" bgcolor="#E8E8E8" class="table_text1"><p align="left">p align="left" style="color:#0d4c7d"><?php echo $rgat;?></p></td></tr> <tr><td valign="bottom" width="200" bgcolor="#E8E8E8" class="table_text1"><p align="left">strong>Expected Price:</strong></td> <td valign="Left" width="520" bgcolor="#E8E8E8" class="table_text1"><p align="left">p align="left" style="color:#0d4c7d"><?php echo $eprc;?></p></td></tr> <tr><td valign="bottom" width="200" bgcolor="#E8E8E8" class="table_text1"><p align="left">strong>Description:</strong></td> <td valign="bottom" width="520" bgcolor="#E8E8E8" height="25" class="table_text1"><p align="left"><?php echo $descr;?></p></td></tr> <tr ><td><p align="left"> </p></td></tr> <?php } ?> <!--</tr> --> </table> </div> code is not working properly - El Forum - 08-23-2012 [eluser]l1v1[/eluser] You have to give us more information. What error exactly do you get? code is not working properly - El Forum - 08-23-2012 [eluser]srpurdy[/eluser] This is posted in the wrong section. But anyway. This is a mess. change to this in yuor controller. Code: // $data['countries'] = $this->Model_form->get_countries(); change your model function to this Code: public function display() I think this is what you really want. Although maybe you want a join. than in your view just do one loop Code: <?php foreach($query as $row) or Code: <?php foreach($query as $row):?> |