Quantcast
Channel: Topic Tag: MySQL | WordPress.org
Viewing all articles
Browse latest Browse all 5540

duucmeister on "Can't get a WP query working"

$
0
0

Hi there!
I am working on a website which contains a class which echoes data from the database to the frontend. The data is stored in the usermeta table. I have added an extra field to the usermeta table using the Advanced Custom Fields module. The query as it is now (without the extra field) is:

if ($_POST['plaats'] != '') { $meta_query[] = array('key' => 'city', 'value' => $_POST['plaats'], 'compare' => 'LIKE'); }

(plaats being Dutch for city)

The query should be something like SELECT * FROM usermeta WHERE $_POST['plaats'] LIKE city OR $_POST['plaats'] LIKE city2

I got this far:

if ($_POST['plaats'] != '') { $meta_query[] = array('key' => 'city', 'value' => $_POST['plaats'], 'compare' => 'LIKE');
$meta_query[] .= array(
'relation' => 'OR',
array(
'key'     => 'city2',
'value'   => $_POST['plaats'],
'compare' => 'LIKE'
)
); }

But as you might guess I cannot get it to work.

Any help would be greatly appreciated!
Thanks!
A WordPress newbie :)


Viewing all articles
Browse latest Browse all 5540

Trending Articles