S
S
Soho2015-09-22 10:05:23
PHP
Soho, 2015-09-22 10:05:23

How do I get an exact match when entering an ID?

Hello everyone, the essence of the matter is as follows - the site has a form for searching real estate by ID, so when we enter, let's say 0049, we get all the real estate containing this ID (example 00049.00498), but we need to display an exact match.
Here is the code responsible for the ID parameter

/* Property ID Parameter */
        if( isset($_GET['property-id']) && !empty($_GET['property-id'])){
            $property_id = trim($_GET['property-id']);
            $meta_query[] = array(
                'key' => 'REAL_HOMES_property_id',
                'value' => $property_id,
                'compare' => 'LIKE',
                'type'=> 'CHAR'
            );
        }

Thanks for the help!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Romanenko, 2015-09-22
@focuspro

'compare' => 'LIKE',change to'compare' => '=',

R
Ruslan Sadikhov, 2015-09-22
@fsdsdfsfdsfsdfsdfsdfsdfsd

LIKE is not needed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question