Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Html Clickable To Advanced Search


ComicWisdom

Recommended Posts

The below code will search in both the description and the tags for a product.

 

In the same table (products_description) I have created a field 'products_continent'

does anyone out there give me a hint as to how I can get the below code to also search that field?

 

 

<a href="http://www.mydomain.com/catalog/advanced_search_result.php?keywords=North America&search_in_description=1&search_in_tags=1">North America</a> 

 

Thank you,

Ralph

Just between us, remember there are only 10 kinds of people in the world; those who understand binary and those who don't!!

 

Remember, learning is a "do-it-yourself" experience; although, not necessarily a "do-it-BY-yourself" experience.

 

The quickest way to learn is to forget to BACKUP!

Link to comment
Share on other sites

The search feature has [ and, or, () ] functionality.

 

	for ($i=0, $n=sizeof($search_keywords); $i<$n; $i++ ) {
  switch ($search_keywords[$i]) {
	case '(':
	case ')':
	case 'and':
	case 'or':
	  $where_str .= " " . $search_keywords[$i] . " ";
	  break;
 }
}

 

If you are hard coding links you might want to try using a + instead of a space.

 

Like this

 

Massachusetts+or+MA

Link to comment
Share on other sites

So with that said you would add additional tables to the search like so.

 

advanced_search_results.php ~261

 

if (isset($HTTP_GET_VARS['search_in_description']) && ($HTTP_GET_VARS['search_in_description'] == '1')) 
$where_str .= " or pd.products_description like '%" . tep_db_input($keyword) . "%'";

 

if (isset($HTTP_GET_VARS['search_in_description']) && ($HTTP_GET_VARS['search_in_description'] == '1')) {
 $where_str .= " or pd.products_description like '%" . tep_db_input($keyword) . "%'";
 $where_str .= " or pc.products_continent like '%" . tep_db_input($keyword) . "%'";
}

 

Also add to the $from_str 'products_continent pc'

Link to comment
Share on other sites

One last bit I don't understand about these two lines.

 

$where_str .= " or pd.products_description like '%" . tep_db_input($keyword) . "%'";
$where_str .= " or pc.products_continent like '%" . tep_db_input($keyword) . "%'";

 

Both of these fields are in the same table "products_description"

Why is one line

pd.products_

and the next line

pc.products_

 

Thank you,

Ralph

Just between us, remember there are only 10 kinds of people in the world; those who understand binary and those who don't!!

 

Remember, learning is a "do-it-yourself" experience; although, not necessarily a "do-it-BY-yourself" experience.

 

The quickest way to learn is to forget to BACKUP!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...