Link to home
Start Free TrialLog in
Avatar of JiveMedia
JiveMediaFlag for Australia

asked on

Website Search using PHP MYSQL

Hi,

Im looking to build a website search that searches a variety of database fields in multiple tables.
I have a main category table and a sub category table, both stores main page content and descriptions, names etc. When someone types in computer for example, i want the selected fields in both tables to be searched and then return the results to the search.php page.
Example of Database Tables

Category
-----------
category_id
category_name
category_content

Sub Category
sub_category_id
sub_category_name
sub_category_content

HTML Form for Search on index.php
----------------------------------
<form  method="get" action="search.php" id="search-form">
<label for="search">Website Search</label>
<input name="search" type="text" value="" />
<input type="submit" name="submit" value="Search" id="search-button">
</form>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of asafadis
asafadis
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JiveMedia

ASKER

Thanks for the comment :)

Im using dreamweaver cs4, do i put this info into the recordset advanced sql dialog box?
Sorry, still fairly new to sql.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry, missed a ; from the code, change line 18 to read
echo '<p>' . $searchresults . '</p>';

Open in new window

Avatar of innotionent
innotionent

In addition. It's possible that you might want to add the % wildcard to your LIKE. That way you can match partial results.

example:
select * from table where foo like 'bar'
Returns only results where it matches bar

Select * from table where foo like '%bar%'
Returns results where bar is in a word.

Thanks!