Welcome Guest, Not a member yet? Register   Sign In
code is not working properly
#1

[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">
&lt;?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;


?&gt;
<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=&lt;?php echo $id; ?&gt;">&lt;?php echo $make;?&gt;&nbsp;&nbsp;&lt;?php echo $model ;?&gt;</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">&lt;?php echo $km ;?&gt;</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">&lt;?php echo $bdty;?&gt;</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">&lt;?php echo $rgat;?&gt;</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">&lt;?php echo $eprc;?&gt;</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">&lt;?php echo $descr;?&gt;</p></td></tr>
<tr ><td><p align="left">&nbsp;</p></td></tr>
&lt;?php

}
?&gt;
&lt;!--</tr> --&gt;

</table>
</div>
#2

[eluser]l1v1[/eluser]
You have to give us more information. What error exactly do you get?
#3

[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();
//  $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();

change your model function to this
Code:
public function display()
  {
  $make = $this->input->post('mkno');  
  $model = $this->input->post('modno');

  $query = $this->db
     ->where('tbl_sel.mk', $make)
     ->where('tbl_sel.md', $model)
     ->where('mktruck.mkno', $make)
     ->where('mkmodel.modnm', $model)
     ->select('
             tbl_sel.id,
             tbl_sel.km,
             tbl_sel.rgat,
             tbl_sel.bdty,
             tbl_sel.eprc,
             tbl_sel.desr,
             mktruck.mkcmpny,
             mkmodel.modnm
      ')
    ->from('tbl_sel,mkmodel,mktruck')
    ->get();
return $query->result();
}

I think this is what you really want. Although maybe you want a join.

than in your view just do one loop
Code:
&lt;?php foreach($query as $row)
{
}
?&gt;

or

Code:
&lt;?php foreach($query as $row):?&gt;

&lt;html here&gt;

&lt;?php endforeach;?&gt;




Theme © iAndrew 2016 - Forum software by © MyBB