如何将$ row作为图像回显?

时间:2019-04-06 04:54:04

标签: php

我试图回显产品的平均评分,但我想回显产品的平均评分而不是数字。我尝试了建议的解决方案,但似乎都没有用。

我尝试过:

<a href=\"{$row['average_rating']}\"><img src=\"IMAGE_URL_GOES_HERE\" /></a> 

之类的东西,似乎都不起作用。

这是我的图片代码:

<img src='../public/images/star.png' height='20px' width='20px'/>

我的function.php代码:

function reviews_average(){

            $avgproduct_id = escape_string($_GET['id']);

            $avgquery = 
"SELECT avg(rating) as average_rating FROM reviews WHERE product_id = $avgproduct_id";
            $avgresults = query($avgquery);
            confirm_query($avgquery);

            while($row = fetch_array($avgresults)){

            ***This is the one I want to display as an image*** 
            $avgratings = "{$row['average_rating']}";
            ***END*** 


            echo $avgratings; 
   }
 }

0 个答案:

没有答案