JiveMedia
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.
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>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, missed a ; from the code, change line 18 to read
echo '<p>' . $searchresults . '</p>';
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.
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.
ASKER
Thanks!
ASKER
Im using dreamweaver cs4, do i put this info into the recordset advanced sql dialog box?
Sorry, still fairly new to sql.