Part1: What do I need to get started?
Since I am doing this locally on my machine For this to work you will need to have the software below installed. Also if you want to apply this to your live web site, your hosting company need to run PHP MYSQL
-
WAMP5 : http://www.wampserver.com/en/index.php
-
EMS SQL Manager for MySQL (WAMP5 comes with a sql manager, you can use it, or which ever one you are familiar with.
Download and install both software, if you installed wamp5, by default it would create a folder located in C:\wamp\www\, create two more folders inside the www\ directory called localroot and the other webroot.
Part2: First you will need to setup your database as shown below. I have an older version than wants shown above. You can also use other MySQL managers that you are use to.
The table name is "table2" with different fields, title, date, description, and category. I also entered Data into this table shown below.
In this tutorial I will setup a site search to search the contents stored in the title and description. And using a dropdown menu you will be able to specify what portion of the category you want.
Part3: With your database setup, Start up Dreamweaver and click New Site Manage Sites.
and click New Site. Click on the Advanced Tab and you will see the window below. Click on Local Info and fill in the information shown.
Click ok and Done, when you are satisfied. Create a new php page and name it search.php. Copy the code below and paste it onto your search page.
After doing that you should have the form below.
Save your page (Ctrl+S). The action is set to /webroot/sitesearch/result2.php so if your directory is different remember to change this.
Part4: Creating the result page.
Click on Bindings in the Application window
With that click on the + and select Recordset
After selecting recordset you will see the window below. If not click on Advanced. In the SQL window add the code shown below.
SELECT *
FROM table2
WHERE title LIKE colname OR table2.description LIKE %mydesc% AND table2.category LIKE %search%
Now in the Variables window click on the +
By doing that it should bring up the window below. Fill in the information shown.
colname
mydesc
search
With that you should have the setup below.
Click ok to save the settings.
Part5: Display the search results.
Create the table shown below. This is a setup to display the content when its search for.
Click on the (+) next the recordset
Now click on the field names and drag it into the table to get the effect shown below.
Click on the table and in the taskbar you will see the tag shown below.
Click on the Table tag to select your table. In the Application Window click on Server behavior. Click on the and select Repeat Region
This allows you to specify how many records or items you want to display on the page. Enter a number and click ok. Below the tables you just create type the information shown below.
Highlight the text, In the Application Window click on Server behavior. Click on the select Show Region and Show If Recordset is Empty.
Finished:
Well that is it, hope it came out to what you expected. If you have any question or comment about this tutorial, feel free to post a message on the forum. I also created a video tutorial for this example. The file is a 9.44 MB flash file. I have the link up on the video section on the forums. Users have to register to view the file, because of spam after you register. Email me at markc1822(at)pixeldigest.com with your user name and I will activate your account. Click here to register.
This Tutorial was Created By Mark
© 2007 pixeldigest.com. All Rights Reserved. |