user7441072
user7441072

Reputation: 279

codeigniter query issue with where condition

I have to write a query to fetch one product data from table. but that product name has a space in between words that is not getting from table using where condition.

public function get_data_print1($item, $start_date, $end_date) {      
  $this->db->select('*');
        $this->db->from('duplex');
          $this->db->where("item_name",$item);
  $this->db->group_by(array("item_name"));

         $this->db->where('duplex.item_dated >=', $start_date);
        $this->db->where('duplex.item_dated <=', $end_date);
        $query = $this->db->get();
       return $query->result();
 }

product name in my table is: duplex180 17x30

Upvotes: -1

Views: 224

Answers (2)

user7441072
user7441072

Reputation: 279

I solved the issue. It was not a query issue. Actually when I post item name full name not get posted because i didnt put that with double quotes.

<select class="form-control" name="item"  id="item" >
  <option value="">----Select------</option>
  <?php 
  foreach($items as $ven) {
      echo '<option value="'.$ven->item_name.'">'.$ven->item_name.'</option>';
  }
  ?>
</select>

Upvotes: 1

Sujal Patel
Sujal Patel

Reputation: 2532

Try This :

$this->db->select('*');
$this->db->from('duplex');
$this->db->where("item_name",$item);
$this->db->where('duplex.item_dated BETWEEN $start_date AND $end_date');
$this->db->group_by(array("item_name"));
$query = $this->db->get();

Upvotes: 0

Related Questions