CREATE  SPECIFIC  SEARCH  RESULTS

In this section I am going to show you can create a Search Engine web page for your website, using a MySQL Database and PHP Scripts, that has your own specific search results inside it. You control the links and the keywords, so your visitors are given the correct web page to visit based on their search.

Begin by downloading the php script, which is contained inside a zip file, from http://aeoncube.com/products.php. Once the zip file (aeoncube_easy_search_v1.0.zip) has been downloaded, into your DOWNLOADS folder for example, extract (unzip) it. If you use Windows Vista to extract the zip file you will be left with a folder called aeoncube_easy_search_v1.0 inside the DOWNLOADS folder, and inside that folder will be a sub-folder called easy_search. In which case, make sure you are inside that sub-folder. Regardless of how you extract the zip file, and to where, you will still have a folder with the following files inside it.



Fig 1.0  Double click on the config.php file to change the MySQL Database connection details

The first thing you need to do is create a MySQL Database for these search scripts. Read the How To Create A MySQL Database section if you do not know how to do this. Give the mysql database a simple name like database or findit. Remember. Your control panel might give your mysql database a prefix that is named after your website user name. For example. I have created a mysql database called findit but it is prefixed with website1_ so it is now known as website1_findit. The mysql database is very important because it is going to store information about your search keywords and so on.

THE  DATABASE  CONNECTION  FILE

After creating your mysql database and mysql database user name you need to double click on the config.php file (Fig 1.0 above) and change the mysql database connection details inside it. Once you have done that simply resave the file. Click on the FILE menu and then select the SAVE menu-item. This will save the file to the same folder, same file but now with your modifications inside it. Fig 1.1 shows the original, empty template, mysql database connection details for the config.php file and Fig 1.2 shows my proper mysql database connection details for the config.php file.



Fig 1.1  The original, empty template, mysql database connection details for the config.php file




Fig 1.2  FILE menu >> SAVE your proper mysql database connection details for the config.php file

The configuration settings are quite straight forward. The Admin Settings and Start Date are not used (probably for future features?). The MySQL Settings are your mysql database Server (normally localhost), database Name, database User Name and database Password. The rest of the settings are self-explanatory.

With the config.php file re-saved with your modifications inside it the next thing to do is create some Table information for the mysql database. Read the How To Create A MySQL Database Table section if you do not know how to create a mysql database table.

CREATE  THE  DATABASE  TABLE

A table is basically a list of records (rows of data) that consist of the same Fields (Headings), with each field normally having a different Data Entry. For example. Each record could have fields called TITLE, NAME and EMAIL ADDRESS whereby you would then fill in the Data Entry for each field. So the data (field) entries for record 1 could be Mr, John White and john@websitecreationhelp.com and the data (field) entries for record 2 could be the same as record 1 or they could be different (i.e. Mrs, Jane Smith, jsmith@hotmail.com). Either way. The fields in each record, for that specific table, are always the same (i.e. TITLE, NAME and EMAIL ADDRESS). So if you create two tables (i.e. members and guests), the records in each table can have the same fields or just a couple of fields the same (because they are two separate tables). For example. The members table could have records inside it with fields TITLE, NAME and EMAIL ADDRESS whereas the guests table could have records inside it with fields TITLE, NAME, ADDRESS, POSTCODE.

MySQL has a command that creates a table for you, called CREATE TABLE. It allows you to specify each field's name as well as it field type (i.e. INT, TEXT, etc). To create a table open a text editor such as Notepad, type out your Table command and then save that text file as a .sql (text) file. From there. Use your myphpadmin control panel to either IMPORT that table.sql file into your mysql database or copy and paste it into the SQL console window. Both of these methods are explained in the How To Create A MySQL Database Table section. The search zip file contains a tables.sql file for you to use - You can modify its, pm_search table, fields if you want to but for this example use the original fields.



Fig 1.3  The PM_SEARCH Table you need to create for the Search PHP Scripts

In the above pm_search table you can modify the following fields (field names) if you want to, but this will mean altering some of the other php scripts in order for everything to work properly. TITLE, KEYWORDS, URL, DESCRIPTION, POSTED_ON and VIEWS can be modified but I would only recommend renaming TITLE, DESCRIPTION and POSTED_ON if need be. And even then, I would only modify them slightly (i.e. URL_TITLE, LINK_DESCRIPTION and DATE_POSTED. You can also delete and add fields of course. So you could add `keyword_heading` varchar(100) collate latin1_general_ci NOT NULL default '', and `visitor_rating` varchar(100) collate latin1_general_ci NOT NULL default '', for example. Note: In these changes I have used VARCHAR(100) instead of TEXT and added collate(). VARCHAR allows you to reserve, but not definitely use, a variable number of bytes (VARiable CHARacters). So in this example VARCHAR(100) means; if you do not fill in a field's data entry 100 bytes will be reserved but not used, but if you were to fill in 10 bytes of data entry 10 bytes would be used while the other 90 bytes remain reserved but not used (unused/unpadded). Therefore you do not bloat the mysql database with used, blank, spaces (0 byte values/padded bytes) like the CHAR() declaration. TEXT is similar to VARCHAR but is intended for large amounts of data in a field (i.e. 65535 bytes) and therefore much slower to process than VARCHAR. VARCHAR used to be limited to 255 characters/bytes but has now been upgraded to 65535. Do not worry too much about TEXT and VARCHAR. Just keep to TEXT if you are not comfortable with MySQL coding.

The INT field is needed in all database tables. It is an indexing number that is automatically increased when you add another record (row of data) to the table. The record (i.e. Title, Keywords, etc) will inherit that index number as its ID. So if you insert three records they will have IDs of 1, 2 and 3 respectively for example and the index number will automatically be increased to 4. If you then delete all three records, or even keep them, the next new record will have an id of 4 regardless. And if you were to delete record 2, and so keep records 1 and 3, the next new record would still have an id of 4. So the index number is totally separate from the id - The id is only formed from the current index number. The number 10 means the id can be up to 10 digits long (millions of records!).

The last line but one (Primary Key) tells the database that you want the ID field to be the primary (master) column or primary (master) identifier. For example. If you made TITLE the primary key it would be useless because the primary key is set up to select the table column (field) whose data uniquely identifies each record. Two titles the same cannot be used as unique identifiers whereas an index number, that is automatically increasing, can be because you would never have two index numbers of the same value. In other words. A unique, automatically increasing, index number is set up for each record so that each record can be uniquely identified by its unique ID number. Primary Key is also used in MySQL Programming but do not concern yourself with that! The last line just completes the CREATE TABLE sql instruction.

UPLOAD  THE  FILES

At this point you should have a mysql database set up (i.e. website1_findit) that contains the above PM_SEARCH table; and a config.php file that contains the mysql database connection details for that mysql database. If so, the next thing to do is upload the search php script files to your public_html (website) folder. An example of how to connect to your public_html folder is given in the How To Connect To A Website Folder Via FTP section. Once you are connected to your web space and have the public_html folder open simply Copy & Paste the following files into it, from the sub-folder called easy_search.



Fig 1.4  Select these files only and then COPY them into memory

As you can see. All of the files are needed except the tables.sql file. It is only needed to manually create the mysql database table. So copy all of the files, except the tables.sql file, over to your public_html folder.



Fig 1.5  PASTE the copied files, from memory, into the public_html folder.

With the files uploaded the next thing to do is login to your MYPHPADMIN control panel, so that you can then fill in the field data for the pm_search mysql database table.

FILL  THE  TABLE  WITH  DATA

After logging into your MYPHPADMIN control panel select your mysql database (i.e. findit), select the pm_search mysql database table and then click on the INSERT Tab (window). Doing so will allow you to enter your keywords and so on into the relevant fields.



Fig 1.6  Enter your keywords, descriptions and so on into the relevant fields - Click on the GO button to submit your data.

A quick look at the PHPMYADMIN control panel, in terms of its layout, should tell you that it may be ideal for creating tables but it is not ideal for filling in table data - The edit boxes are way too big for a start. Luckily. The search php scripts contain a script called submit.php that allows you to easily fill in your table data. To launch the script simply type your website address (url) into a web browser followed by /submit.php (i.e. www.websitecreationhelp.com/submit.php) and then either click on the GO button or press the ENTER keyboard key. From there. Enter your TITLE, KEYWORDS, URL and DESCRIPTION data before clicking on the SUBMIT button.



Fig 1.7  Enter your keywords, descriptions and so on into the relevant fields - Click on the SUBMIT button to submit your data.

When you are typing in your keywords you can separate them with a comma, space and so on to give different search results. For example. If I have the keywords printer monitor submitted with url www.1.com and keywords printer, monitor submitted with url www.2.com they will produce different results. Anyone typing printer monitor will be shown the url www.1.com and anyone typing printer, monitor will be shown the urls www.1.com and www.2.com. This is because search one is searching for the specific keyphrase printer monitor (no comma separating the keywords) whereas search two is searching for anything with the two keywords (printer and monitor) inside it. Therefore. You might want to make your visitors aware of this.

If you do not want to use the submit.php script, for whatever reason(s), you might want to download/use the Database Viewer/Editor (Manager) called VTY (as exampled in the How To Create A MySQL Database Table section. VTY is a free, one file only, PHP Script that enables you to manage your MySQL Databases online. There is nothing to install. Simply Download VTY, upload it to your public_html folder and then type www.yourdomain.com/vty.php into your web browser.

When you have finished submitting all of your table data simply give your visitors the address of your index.php web page (i.e. www.yourdomain.com/index.php). Although it would be great to embed the SEARCH edit box, and search results, directly into your own web pages (which is possible) I would recommend incorporating/applying your website's design into the index.php and submit.php files (web pages) instead. Doing it the other way around, incorporating the index.php and submit.php files (php code) into your web pages, is not really ideal (especially as an absolute beginner). It would take some mighty programming to achieve that. Meaning. It is possible but you would need to pay a PHP programmer, which would be expensive and not worth it.....you would be better off buying a professional search php script. Saying this. This script is quite adequate for general purposes. The beauty of it is its simplicity - It has not been flooded with extra code and unwanted features. Hence its title Easy Search.

At the time of writing Web Hosting Providers, PHP, MySQL and Security in general are all being updated. This may mean the easy search scripts do not work on your specific web hosting provider's server (your website) unless you add the following instruction to the top of the submit.php and index.php code: <?php extract($_POST,EXTR_SKIP); ?>.

Create Membership Login Account Index ???