Skip to main content


Showing posts from July, 2008

Performing Simple String Search Using PHP and MySQL

Here it is, a post after so long! We see “Search” feature on almost all websites. Some employ third-party tools (like Google Custom Search) while others, mostly CMS based websites, have their own Search feature. The question now is, How do Search Feature Work? Answer is, it (almost always) uses MySQL (or database server’s capability. You all might be knowing that CMSs always store information in databases. So if we can search that we can very well search the whole site! So today we’re going to employ the feature of MySQL to perform simple searching. As an example we’ll be creating an Online Phonebook to illustrate this. MySQL’s Simple Search (String Matching) Query select [coulumn1] from [table] where [column2] like ‘$var%’ (For some of the basic SQL queries refer to MySQL Commands ) we’ll take a simple example to illustrate the above query. Suppose we have a table with the following rows and columns : id column-1 column-2