Skip navigation
Currently Being Moderated

Search for a record by number

Jan 14, 2011 8:30 AM

I've created two search fields.

 

Search field 1 - Search by entering a city name (or a partial city name) - this works fine. (I am using the 'colname3' variable for this).

 

Search field 2 - I want the user to search by number with an exact match, e.g. they enter '123456' to return record '123456' from the database.

 

I can't seem to get this to work properly, at the moment I'm using the 'colname3' variable below which returns partial results e.g. '123' returns result '123456'.

 

How can I modify this so the user has to enter the exact number to return the required result?

 

 

This is the variable I'm using:

 

Name:colname3

Type: text

Default value: -1

Runtime value: $_GET['jobnumberfield']

 

 

This is the SQL statement:

 

SELECT *
FROM joinversion3
WHERE job_no LIKE %colname3%

 
Replies
  • Currently Being Moderated
    Jan 14, 2011 11:50 AM   in reply to Wookie

    For exact match use = argument instead of LIKE argument. Setup conditional statement where if LIKE form is submitted then run LIKE query elseif exact match form is submitted run exact match query.

     

    SELECT *

    FROM joinversion3

    WHERE job_no = $colname3

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points