So I have created a function on a separate php inc page and want to output the single result of the function on another page.
This is the function
function get_all_rating_criteria_travel5(){
global $wpdb;
$query = "SELECT RatingCriteriaText from ratingcriteria WHERE NicheID=1 AND StarRatingID=5";
$result = $wpdb->get_var($query);
}
On the page I want the result I put this
<?php echo get_all_rating_criteria_travel5($result->RatingCriteriaText); ?>
I get no errors, but no result. I have tested the SELECT Query in PHPMyadmin and that produces exactly what I want. Can anyone help, I've spent hours combining different variations and I cant get it to output the database result field. I'm sure its something stupid.
EDIT: I can do this on the page and it works, but how do I do this as a function
<?php
global $wpdb;
$rating5 = $wpdb->get_var( 'SELECT RatingCriteriaText from ratingcriteria WHERE NicheID=1 AND StarRatingID=5;')
?>
<?php echo $rating5 ?>