dp13668681869 2019-01-28 19:53
浏览 171

php头像图像和真实图像显示

I am creating PHP products view page. I want to display products uploaded by user profile pic and if not updated user real image should be displayed avatar image. My script is working but not showing avatar image I have tried to make but it's not working

Here is my code

<?php
    if(isset($_GET['srcid'])) {
        $srcid = $_GET['srcid'];
        if($stmt = $con->prepare("SELECT p.*,c.cat_title,u.username,u.profile_pic,title,desc1,time,img,img1,img2,img3,views,id FROM products AS p 
            JOIN users AS u ON u.user_id= p.user_id
            JOIN category AS c ON c.cat_id = p.cat_id
            WHERE id=?")){
                $stmt->bind_param("s", $srcid);
                $stmt->execute();
            }
    }
    $result = $stmt->get_result();
    if($result->num_rows > 0){
        while($row = $result->fetch_array(MYSQLI_ASSOC)) {

?>

<div class="article">
<?php
    $profile_pic = $row['profile_pic']; 
    if ($profile_pic == '') {
?>

<img src="user/icons/avatar.png " width="100" height="100"  style=" margin-top:-20px; float:left;"/>    

<?php
    }else{
?>

<img src='user/profile_picture/<?php echo  $row['profile_pic'];?>' width='150px' height='130px'  style=' float:left;  border:0px solid #ddd'>
<font color="#f90" style="padding:3px;font-family: 'Oswald';">ARTICLE POSTED BY:</font><a href="profile.php?u=<?php echo  $row['username'];?>"><?php echo  $row['username'];?></a></div>
<p class="v-p1"></p>
<?php 
            }
        }
    }
?>
<div class="uploaded"></div>
  • 写回答

2条回答 默认 最新

  • dqu92800 2019-01-28 19:59
    关注

    null does not always equal '';

    try if (strlen(trim($profile_pic)) == 0) {?>

    评论

报告相同问题?

悬赏问题

  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条