RFree190:
/index.php?main_page=advanced_search&search_in_description=1&keyword=6171 6175 6182 6189
But, running this URL gives this message, "There is no product that matches the search criteria."
Spaces aren't allowed in URL's
That won't be your entire problem though. Even if/when you add a delimiting character to remove the spaces you'll need to modify the advanced search page so that it can retrieve and act upon the individual 'keywords'.
RFree190:
What would be the proper way to construct the URL before allowing the user to link to the advanced search page? I tried adding OR between each number, but then it gives incorrect results. It will show number 6171 as well as 16171 and 61715. I tried single and double quotes, but both failed.
Try something like this:
// create URL
$URL = /index.php?main_page=advanced_search&search_in_description=1 ;
$temp = urlencode(6171 6175 6182 6189) ;
$URL .= "&keyword=".$temp ;
Then on the advanced search page:
// decode URL
$matches = $_GET('keyword') ;
$keywords = preg_split("/ /",urldecode($matches));
// this will produce a keywords array like:
Array (
[0] => 6171
[1] => 6175
[2] => 6182
[3] => 6169
)
You can then use the array values to create your SQL query string, something like
SELECT * from 'some_table' WHERE 'productID LIKE '$keywords[0]' OR 'productID LIKE '$keywords[1]' OR 'productID LIKE '$keywords[2]' OR 'productID LIKE '$keywords[3]' ;
This is just 'off the top of my head' - It may or may not work as advertised, and there are several other methods that you can use rather than urlencode/decode (which is probably an overkill in this situation). Likewise, there are several other methods that you can use to isolate the individual 'keyword' components rather than preg_split. It would also be advisable to create the 'SELECT' string as a variable rather than 'hard coding' the keyword array data, especially since you are unlikely to know in advance how many keywords there will be in any given query/request.
In short, what I've given you is an idea as to the principle requirements needed to make it work. The exact implementation can take many different forms.
The most important thing to realize is that URL's cannot contain spaces.
Cheers
Rod
NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.
Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.