How can I make my select variable match exact |
[eluser]msank[/eluser]
Hey there, I need some help with getting my select statement to return EXACTLY what I asked it to look for, not 'search variable' + anything else that has that in it's value; eg Magnetics is from the row 'name'. I am searching for ALL products from "Magnetics" and ONLY them. Currently I am getting all companies with "Magnetics" in their name... I have tried the following in my model: Code: function searchInventory($search) { but it returns no results. This is my form: Code: <?php This is my controller for the page the form is on: Code: function search() { Any ideas? Thanks!
[eluser]msank[/eluser]
I added that to try to see if it would work, after I was having issues with getting more than I was wanting (Other companies aside from Magnetics) and it would return nothing. Before I added that, it was returning more than I needed, and wanted.
[eluser]Matalina[/eluser]
Code: function searchInventory($search) { did you try that?
[eluser]msank[/eluser]
Yep... That's what I had originally and is returning more than I want.
[eluser]Matalina[/eluser]
1. Why are you using a like statement if you want ONLY Magnetics? Why not a straight Where = clause? Code: $this->db->or_where('name', $search); 2. Use the third parameter (http://ellislab.com/codeigniter/user-gui...ecord.html) Needed quote: Quote:If you do not want to use the wildcard (%) you can pass to the optional third argument the option 'none'. Code: $this->db->or_like('name', $search,'none');
[eluser]msank[/eluser]
Quote: This fixed my issue! Thanks so much for the stellar help! I really appreciate it!
|
Welcome Guest, Not a member yet? Register Sign In |