Jump to content

dimko

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Everything posted by dimko

  1. I have this part of the code: for($number_words_loop = 0; $number_words_loop < $number_words; $number_words_loop++) { $value1 .= 'AND a.adtitle RLIKE \'[[:<:]]' . $words[$number_words_loop] . '[[:>:]]\''; $value2 .= 'AND a.addesc RLIKE \'[[:<:]]' . $words[$number_words_loop] . '[[:>:]]\''; } And I want to combine $value1 and $value2, so the code should look something like this: for($number_words_loop = 0; $number_words_loop < $number_words; $number_words_loop++) { $value .= 'AND a.adtitle RLIKE \'[[:<:]]' . $words[$number_words_loop] . '[[:>:]]\' OR AND a.addesc RLIKE \'[[:<:]]' . $words[$number_words_loop] . '[[:>:]]\''; } In the first code, first it checks $value1 and then $value2 one by one, and that way it checks if both of them contain all the words that are put in the search field. What I need is to check if all the words that are put in the search field are contained in the one OR in the another. I want to make it search through both of them at the same time, but I don't know how to put correctly that OR I put in the second example. So any professional help will be appreciated. Here is an example of what I mean: If the Ad has this: Ad Title: nokia phone on sale Ad Description: brand new, unpacked, with 16gb memory card included. and if someone searches for nokia sale it will show the ad, because all the search words are contained in the Ad Title. Also, if the search is brand unpacked it will also show the ad, because all the search words are contained in the Ad Description. But, the problem is if someone searches for nokia brand This way, the word nokia is not contained in the Ad Description, and the word brand is not contained in the Ad Title, so the ad will not be shown. So, I only need a way to put that OR correctly to connect those two values, just like the second code, but in the right way. Thanks in advance.
  2. I have this code I'm using for a search: if ($xsearch) { $searchsql = mysql_escape_string($xsearch); if ($use_regex_search) { $whereA[] = "(a.adtitle RLIKE '[[:<:]]{$searchsql}[[:>:]]' OR a.addesc RLIKE '[[:<:]]{$searchsql}[[:>:]]')"; } else { $whereA[] = "(a.adtitle LIKE '%$searchsql%' OR a.addesc LIKE '%$searchsql%')"; } } So, what I want to do is to merge a.adtitle and a.addesc, so they become one value, let's say a.admerged or $admerged, I really don't know which one is possible, so the above code should look like this: if ($xsearch) { $searchsql = mysql_escape_string($xsearch); if ($use_regex_search) { $whereA[] = "(a.merged RLIKE '[[:<:]]{$searchsql}[[:>:]]')"; } else { $whereA[] = "(a.merged LIKE '%$searchsql%')"; } } The DB structure, regarding those two values, is like this: In the same table, named ads, there are those two rows, named adtitle and addesc, from which the adtitle contains the Ad Title text of the ad, and the addesc contains the Ad Description text of the ad. So, my idea is to merge those two texts in some new variable, so the search function should see those two texts as a one whole text, not checking them one by one, like it does now with the first code above. Here is one example, just to simplify my explanation: Ad Title: nokia phone on sale Ad Description: brand new, unpacked, with 16gb memory card included. Ad Merged: nokia phone on sale brand new, unpacked, with 16gb memory card included. While merged, it should have empty spece between them. I'm working to improve the search function, to search by phrase, by words, etc, and I need to solve this merging thing first, in order to continue. So, any help is appreciated. The original file with the above code is attached to this post. Thanks to all of you in advance. [attachment deleted by admin]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.