bk1984 Posted June 9, 2009 Share Posted June 9, 2009 Hi all, I am currently trying to fix the search on a website I am trying to develop. What happens is if you search for 'bin' a lot of products come up which contain bin within their product description, this is very annoying as you can imagine because things like post it notes will appear which are totally unrelated. But when I add spaces into the the search for example (space)bin(space) it will come up with the correct products. I am baffled I have search through the code numerous times and just don't know how to do it. I am a beginner at PHP but hoping to quickly learn so I can get the website running functionally how everyone wants it. the code is: <?php $app = $this->globals('khxc_display.app'); $eol = $this->globals('khxc.eol'); $formid = $app . '--minisearch'; $strid = $app . '--prodsearch--string'; $link = $this->link_namespace($app,'prodsearch',array()); $typeid = $app . '--prodsearch--type'; $cgi_value = ''; $this->xhtml_quickform_header($formid,$app,'prodsearchp',array()); print '<p class="hidden"><label for="' . $app . '--minisearch--' . $strid . '"'; print '>Search Term</label></p>' . $eol; print '<p class="inline"><input class="khxc_quickfield" type="text" name="' . $strid; print '" id="' . $app . '--minisearch--' . $strid . '" value="'; print $cgi_value . '" size="22" maxlength="100" /></p>' . $eol; print '<p class="hidden"><input class="khxc_quickfield" type="text" value="EXACT" name=" ' . $typeid; print '" id="' . $app . '--minisearch--' . $typeid . '" value="ALL" /></p>' . $eol; $this->xhtml_quickform_footer($formid,'Online Store Search',1); print '<a class="unfancy" href="' . $link . '" title="Advanced Search">Advanced Search</a>' . $eol; ?> any help would be extremely appreciated Thank you in advance Ben Link to comment https://forums.phpfreaks.com/topic/161494-spaces-in-a-search-box/ Share on other sites More sharing options...
bk1984 Posted June 9, 2009 Author Share Posted June 9, 2009 Sorry not even said what I want to do, I want these spaces to be in automatically both before and after whatever word they type in thanks Link to comment https://forums.phpfreaks.com/topic/161494-spaces-in-a-search-box/#findComment-852234 Share on other sites More sharing options...
scvinodkumar Posted June 9, 2009 Share Posted June 9, 2009 so you want to add spaces, right? if yes, then after submitting the form, add the space in the action file. for example, $search = " ".$_POST['search']." "; Link to comment https://forums.phpfreaks.com/topic/161494-spaces-in-a-search-box/#findComment-852235 Share on other sites More sharing options...
bk1984 Posted June 9, 2009 Author Share Posted June 9, 2009 Thank you very much, I shall now go and have a go. Link to comment https://forums.phpfreaks.com/topic/161494-spaces-in-a-search-box/#findComment-852250 Share on other sites More sharing options...
bk1984 Posted June 9, 2009 Author Share Posted June 9, 2009 Hi, I am sorry to ask you this but what is an action file? Link to comment https://forums.phpfreaks.com/topic/161494-spaces-in-a-search-box/#findComment-852331 Share on other sites More sharing options...
scvinodkumar Posted June 9, 2009 Share Posted June 9, 2009 the filename you mentioned in the form tag <form name="formname" action="actionfile" method="post"> Link to comment https://forums.phpfreaks.com/topic/161494-spaces-in-a-search-box/#findComment-852337 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.