I am using following code in the theme files to get some output from the DB:
<?php $querystr = "SELECT DISTINCT meta_value FROM $wpdb->wp_postmeta WHERE 'meta_key' LIKE 'movie_name' ORDER BY meta_value ASC";
$movie_names = $wpdb->get_results($querystr, OBJECT);
echo sizeof($movie_names);
?>
<ul>
<?php foreach ( $movie_names as $movie_name ){ ?>
<li><?php echo $movie_name->meta_value; ?> </li>
<?php } ?>
</ul>
Above code's result is "0" at the frontend. But when I am running the same query i.e.
SELECT DISTINCT meta_value FROM wp_postmeta WHERE 'meta_key' LIKE 'movie_name' ORDER BY meta_value ASC
in DB then it's returning 6 rows. Please help me in finding the problem in the code.