SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Keyword seach

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jul 2003
    Location
    UK
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Keyword seach

    I am using this query to find particular items.

    Code:
    $result = @mysql_query("SELECT * FROM submission WHERE day = '$subday' AND month = '$submonth' AND year = '$subyear'");
    if (!$result) {
    	die('<p>Unable to locate database. Script is at search level.</p>');
    	}
    What I want to do is change it to something like this:

    Code:
    $result = @mysql_query("SELECT * FROM submission WHERE subtext = '$subsearch'");
    if (!$result) {
    	die('<p>Unable to locate database. Script is at search level.</p>');
    	}
    The problem I have is that as above I want to search the database where the field subtext is equal to $subsearch. If the text is the same for both then it will return the results which is fine.

    The simplest way to explain is that I want to seach for any entry that contains the value of $subsearch but not an exact match.

    *$subsearch* - no matter what is before or what is after.

    Does that make sense?

    Lee

  2. #2
    SitePoint Member
    Join Date
    Jul 2003
    Location
    UK
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, so you look at things long enough and the answer get to your brain!!

    the = sign should have given it away to me. Never mind.

    So the code for those remotely interested should have been

    Code:
    $result = @mysql_query("SELECT * FROM submission WHERE subtext LIKE '%$subsearch%'");
    
    if (!$result) {
    	die('<p>Unable to locate database. Script is at search level.</p>');
    	}


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •