CodeIgniter Forums
search from database using text field and search button - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter Archived (from EllisLab) (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: search from database using text field and search button (/thread-53163.html)



search from database using text field and search button - El Forum - 07-13-2012

[eluser]skhan[/eluser]
Hi! I am newbie here.
i want to create search from database using text field and search button without ajax, javascript or jquery.
i want php using codeigniter framework,

here is my table ('inventory') and my fields are ('id', 'item', 'unitprice', 'qty')

when i search 'an' i want to view all item starts with 'an',

i do login,CRUD, mvc using codeigniter but this one is difficult for me..
someone help me please.

thanks in advance!


search from database using text field and search button - El Forum - 07-13-2012

[eluser]Nisha S.[/eluser]
Do you want to search on all the fields? Then you need to add all the fields with or where clause. Use % at the end since you need to display the results starting with an.

Code:
$searchString = 'an';//get it as parameter
$this->db->like('fieldName',$searchString  . '%');