I'm generating an XML file using PHP for a website where they review tech products. In the XML file, I have to display the rating of products. For rating purposes, I'm using GD Star Rating plugin.
I've been experimenting with wpdb class to fetch the rating of each product. However I've not had any luck so far. I'm using the following SQL code on phpmyadmin and I'm able to to fetch the rating for any product review I want
SELECT review FROM tableName_gdsr_data_article WHERE post_id = 4627
But when I try this SQL code in PHP, as seen below, all I get is bunch of errors.
$post_id = $post->ID;
$reviewScore = $wpdb->query(
$wpdb->prepare(
"SELECT review FROM tableName_gdsr_data_article WHERE post_id = '$post_id'"
)
);
Does anyone have any idea why the code above doesn't work? Any help would be much appreciated.
Thanks in advance