Please help creating search result page of this search form
Moderator: General Moderators
- prasitc2005
- Forum Commoner
- Posts: 42
- Joined: Thu Jul 13, 2006 7:14 am
Please help creating search result page of this search form
Hi all php gurus
I have tried to build quite a complex search page having the search form like this in Dreamweaver PHP:
Search by category: drop down category 1 2 3
Search by details drop down like: size 1 2 3, colour 1 2 3, manufacture 1 2 3
Also containing text:....
How can I code a search result page that can show some products which can have category 1, size 1, colour 2 and contain the text "steel"
etc.
Please help soon! Thanks a lot!
I have tried to build quite a complex search page having the search form like this in Dreamweaver PHP:
Search by category: drop down category 1 2 3
Search by details drop down like: size 1 2 3, colour 1 2 3, manufacture 1 2 3
Also containing text:....
How can I code a search result page that can show some products which can have category 1, size 1, colour 2 and contain the text "steel"
etc.
Please help soon! Thanks a lot!
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
hi prasitc,
just querying it in google gave me plenty of helpful tutorials....
http://www.google.com/search?hl=en&q=bu ... h%2Bengine
I am not an expert in php otherwise, i would have given you a quick/rough starting point as far as the code goes...
BUT, from my understanding of the php language, ole has given an excellent outline to follow.
hopefully this helps,
-Matt
just querying it in google gave me plenty of helpful tutorials....
http://www.google.com/search?hl=en&q=bu ... h%2Bengine
I am not an expert in php otherwise, i would have given you a quick/rough starting point as far as the code goes...
BUT, from my understanding of the php language, ole has given an excellent outline to follow.
hopefully this helps,
-Matt
- prasitc2005
- Forum Commoner
- Posts: 42
- Joined: Thu Jul 13, 2006 7:14 am
Thanks
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Great guidance
Could you give me an example of scripts, please. Anything at all. I can't imagine how long they will be. Thanks!
well I couldn't go farer than this: This is partly just a simple approach. I'm stuck!Code: Select all
<?
$colcid_rs_search_result = "1";
if (isset($_GET['cid'])) {
$colcid_rs_search_result = (get_magic_quotes_gpc()) ? $_GET['cid'] : addslashes($_GET['cid']);
}
$colname_rs_search_result = "1";
if (isset($_GET['searchtext'])) {
$colname_rs_search_result = (get_magic_quotes_gpc()) ? $_GET['searchtext'] : addslashes($_GET['searchtext']);
}
mysql_select_db($database_hydrosql, $hydrosql);
$query_rs_search_result = sprintf("SELECT flow_products.name, flow_products.material, flow_products.manufac, flow_products.detail, flow_products.image, flow_products.pdf, flow_cat.cat_name FROM flow_products inner join flow_cat on flow_products.cat_id = flow_cat.cat_id WHERE name like '%%%s%%' AND cat_name = '%s' ORDER BY flow_products.name ASC", $colname_rs_search_result,$colcid_rs_search_result);
$query_limit_rs_search_result = sprintf("%s LIMIT %d, %d", $query_rs_search_result, $startRow_rs_search_result, $maxRows_rs_search_result);
$rs_search_result = mysql_query($query_limit_rs_search_result, $hydrosql) or die(mysql_error());
$row_rs_search_result = mysql_fetch_assoc($rs_search_result);
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]No one is going to write a script for you. You should simplify your problem into smaller problems (a programmer often call those 'functions'), and deal with each small problems at once. Go one to the next small problems when the first one is working.
When you get in trouble, read the related entry in the appropriate manual. If that fails, Google about the problem, search this forum for someone who had a similar problem, search other appropriate forums. In some case you might even try to split your problem into even smaller problems.
If everything fail, explain your problem here, on as small as possible a problem, as small as possible a code snippet, and as many as possible details. At that point, people will be happy to help. Not before that moment.
This is how forums work.
Hope this helps,
Tom
When you get in trouble, read the related entry in the appropriate manual. If that fails, Google about the problem, search this forum for someone who had a similar problem, search other appropriate forums. In some case you might even try to split your problem into even smaller problems.
If everything fail, explain your problem here, on as small as possible a problem, as small as possible a code snippet, and as many as possible details. At that point, people will be happy to help. Not before that moment.
This is how forums work.
Hope this helps,
Tom
- prasitc2005
- Forum Commoner
- Posts: 42
- Joined: Thu Jul 13, 2006 7:14 am
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
- prasitc2005
- Forum Commoner
- Posts: 42
- Joined: Thu Jul 13, 2006 7:14 am
hi prasitc,
did you try this?
viewtopic.php?t=24222
very very very informative!!! i learned something good (very good indeed) from this.
also check out the last post.... it has the link to another resource that will help you achieve your goal
-Matt
did you try this?
viewtopic.php?t=24222
very very very informative!!! i learned something good (very good indeed) from this.
also check out the last post.... it has the link to another resource that will help you achieve your goal
-Matt
- prasitc2005
- Forum Commoner
- Posts: 42
- Joined: Thu Jul 13, 2006 7:14 am
How can I create result page from this search form?
Thanks Matt. Very useful but the last link was broken. PHP search is such a complex thing. Does anybody know how to do complex search like in Ebay?
How can I create result page from this search form?

How can I create result page from this search form?

Actually you won't do your search with PHP, but with SQL (I'm guessing your data is stored in some database, not a flat file). PHP will just be used for manupulating the search data and display it on the screen.
In SQL, 'any' is read as %, so should do the trick.
for the keywords, your query will look like:
Hope this is a good starting point for your quest, but this isn't an SQL forum, is it?
Tom
Code: Select all
$result = mysql_query("SELECT * FROM digital_cameras WHERE type IS LIKE '$type' AND brand IS LIKE '$brand' AND resolution IS LIKE ........");Code: Select all
WHERE type IS LIKE '%'for the keywords, your query will look like:
Code: Select all
SELECT * FROM digital_cameras WHERE type IS LIKE '%$keywords%' OR brand IS LIKE '%$keywords%'..............Tom
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
PHP - Code is not an SQL forum, but Databases is.Tom420 wrote:Hope this is a good starting point for your quest, but this isn't an SQL forum, is it?
I really believe fulltext is easier and better for search engines. Like is very unpredictible and returns things like category when you search for cat. Not only that fulltext will take a string of words where like needs prefomatting.ole wrote:Build an SQL query with them that fetches the data using things like WHERE `field` LIKE 'value'