Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for. Apr 30, 2016 I'm going to show you how to create simple search using PHP and MySQL. You'll learn: How to use GET and POST methods Connect to database Communicate with database Find matching database entries with given word or phrase Display results You. May 23, 2017 This is the main file that generates AJAX request for the server and returns the results. Create a file named ajax.php, and paste the following code in it: php //Including Database configuration file. Include 'db.php'; //Getting value of 'search' variable from 'script.js'. Source code free download - The Source Code, VLC Media Player source code, ASP.NET Shopping Cart Source Code, and many more programs. Enter to Search. My Profile Logout. Edit programs in. Get the free code of the Quran and Hadith Search for your website: You can use the following source codes to search in the Quran and the Hadith in your website. You just need to copy the code and paste in your website at any required position. If you get any problem.
Maian Search is free PHP software released under the Creative Commons Licence. It is a very simple search system, ideally for someone who has a static HTML website and needs search functionality. It`s not responsive, but it does support PHP5.6. & PHP7. A new version may appear in the future.
PHP & Planet Source Code news and announcements
PHP Categories - Browse the largest code database on the net!
Winners for code submittedWinners for code submitted February 2020 as chosen by your votes!
|
I'm just a few days away from launching a comprehensive support website for my book, 'Beginning PHP and MySQL 5, Second Edition', and among other features, have built a search engine for sifting through the more than 500 code snippets found throughout the book. This was an interesting exercise because it involves a number of storing a fairly significant amount of text within a MySQL database, using MySQL's full-text search facility, and devising an effective way to extract and display the code in the browser.
In this article I'll offer a simplified version of this search engine, introducing you to some compelling PHP and MySQL features along the way. You might adopt what you learn towards building your own search engine, or towards other applications.
The Database Schema
Just a single table is required for the engine's operation. The table, code, serves as the code repository. Each example is stored along with a suitable title and the chapter number in which it appears. Because the search engine should retrieve examples based on keywords found in the example title or in the code itself, a FULLTEXT index has been added for these columns. Because the table contents will rarely change beyond the occasional bug fix, its backed by the read-optimized MyISAM storage engine. The table follows:
Loading the Table
The downloadable zip file containing all of the book's code should be easily navigable so readers can easily retrieve the desired example. To meet this requirement, the zip file contains a number of directories labeled according to chapter number (1, 2, 3, ... 37), and each script is aptly named with a lowercase title and series of underscores, for example retrieving_array_keys.php. Therefore a script capable of dealing with these two organizational matters is required in order to automate the process of loading the scripts into the database.
You might recognize this task as one well suited for recursion, and indeed it is. The following script does the job nicely:
I've purposefully left two printf() statements in the script so you can view the script's logic. Some sample output follows:
Building the Search Engine
With the code and corresponding metadata inserted into the database, all that's left to do is build the search engine. Believe it or not, this is perhaps the easiest part of the project, thanks to MySQL's fulltext search capabilities. Although I've used the symfony framework to abstract the database interaction, for the purposes of this article I've used POPM (Plain Old PHP and MySQL) to build the search engine. The search form is exceedingly simple, and looks like this:
The search script (search.php) looks something like this. Provided you've used PHP to interact with MySQL before, there shouldn't be any surprises, except for perhaps the query itself. This query takes advantage of MySQL's fulltext feature to compare the keyword against those columns that have been identified as searchable using MySQL's fulltext conditions. These conditions can produce unexpected results without doing some advance reading, so be sure to peruse the appropriate section of the MySQL documentation before building your own queries.
Page 1 of 2
This article was originally published on April 11, 2007
IT Solutions Builder TOP IT RESOURCES TO MOVE YOUR BUSINESS FORWARD