Correct PHP to output a single result of a Function with SQL Query


So I have created a function and want to output the single result of the function on a 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.

pinkequine 3 months 0 Answers 10 views 0

Leave an answer