Reputation: 475
Can any one tell me that how i can get name when value is separated by comma in where clause.
This is what i tried:
$this->db->select("seller.name");
$this->db->from("seller");
$this->db->where("id",'29,25');
$q = $this->db->get();
$res = $q->row_array();
echo $res['name'] ;
I want to print all name with id 29,25 without using another where query but mine is printing only one with id 29
Upvotes: 0
Views: 78
Reputation: 16117
If you want to use two ids in where clause than you can use where_in
like:
$this->db->select("name");
$this->db->from("seller");
$this->db->where_in("id",array(29,25));
$q = $this->db->get();
$res = $q->result_array();
Here ids use as an array array(29,25)
For printing the result use foreach loop
:
foreach($res as $value){
echo "Name: ".$value['name'] . "<br>";
}
Upvotes: 1