Problem getting meta_value data from database
-
Hi. I’m trying to put together a list of all posts where the metadata matches a specific query. It appears to work fine until I try to output the data, at which point it is repeated continuously.
I expected it to display 16 23 but instead it shows 16 23 16 23 16 23 16 23 16 23 16 23 16 23 16 23 16 23 16 23
Here’s the code:
<?php global $wpdb; $results =$wpdb->get_results("SELECT post_id FROM $wpdb->posts , $wpdb->postmeta where $wpdb->postmeta.meta_value = '2015/06/03' AND meta_key='mymvkey'", OBJECT); foreach ($results as $result){ print_r ($result->post_id); } ?>I’m still trying to get the hang of handling arrays (and not just in php) so that’s probably where I’m going wrong. But every post I’ve read suggests that this should work. Also, I’ve tried it both in and out of the loop with the same result. Is there any way to just display the data once instead of repeatedly?
The topic ‘Problem getting meta_value data from database’ is closed to new replies.