Welcome Guest, Not a member yet? Register   Sign In
How can be better to select from db all users that have name begining from "A" ?
#1

[eluser]New One[/eluser]
for example i have db 'users' and field 'name'
How can be better to select from db all users that have name begining from "A" ?

$this->db->where('name',"like '%A'");
$data['query'] = $this->db->get('users');

but i think that something is wrong here :$this->db->where('name',"like '%A'");
please help
#2

[eluser]Seppo[/eluser]
$this->db->like("name","A%");
#3

[eluser]New One[/eluser]
Thanks. But now the new problem is :

I have a $temp (it can be A or B or Z etc.)
how can i use it now?
$this->db->like("name”,"$temp%");
or
$this->db->like("name”,".$temp.%");
or
$this->db->like("name”,"$temp.%"); Doesn't help. Sad
#4

[eluser]MattKern[/eluser]
try

$this->db->like("name”,$temp."%");

It should work - I am not on a machine I can actually test it on. Sorry....
#5

[eluser]New One[/eluser]
looks like it doesn't helps.

it search the symbol in all string.




Theme © iAndrew 2016 - Forum software by © MyBB