php该怎么输出图片?

我从数据库获取到本地图片的路径,存到$img中,然后该如何输出让其显示图片?

img

    include ("conn.php");
    if(!empty($_GET['sub'])){
        $key=$_GET['keys'];
        $t = " title like '%$key%'";
        //echo "$t";
        //$t = 1;
    }else{
        $t = 1;
    }
    $sql ="select * from test where $t order by id desc limit 20";
    $query = mysqli_query($link, $sql);  // 执行一次
echo '<div class ="row">';
    while($rs = mysqli_fetch_array($query)){ //循环打印每一篇博客
    
?>
<div class = "column">
<h2 style="text-align:center;"><a href="view.php?id= echo $rs['id'];?>" style="text-decoration: none;color:#555555;"> echo $rs['title'];?>a> h2>
<li style="text-align: right;"> echo $rs['data']?>li>
  $img=$rs['avatar'];    ?>  
 
<p style="font-size:18px;"> echo iconv_substr($rs['contents'],0,10,"utf-8"); ?>p>
div>


其实在你写的代码中,a链接已经有可以复用的代码了。
<a href="view.php?id=<?php echo $rs['id'];?>"
href是HTML的元素,是链接地址;通过php输出的值。
所以你用PHP和HTML结合就可以了,HTML的img标签+PHP输出的内容即可。