Jump to content

Little help with a SEARCH code I have


dimko

Recommended Posts

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]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.