du13932014807 2017-06-05 14:13
浏览 8

我的代码出了什么问题? (从DB中选择所有不工作)[关闭]

Long time that i dont program php.

i made a function for the cliente profile,so the cliente can see his logo

this is the cliente code

function display_logo(){
    global $conn;

    $stmt = $conn->prepare("SELECT LogoImage FROM usuarios WHERE email=?");
    $stmt->bind_param("s", $em);
    $em = $_SESSION['useremail'];
    $stmt->execute();
    $result = $stmt->get_result();
    $rows = $result->fetch_assoc();

    $img =$rows['LogoImage']; 
    echo '<img style="    margin-top: -14;
    object-fit: contain;" src="includes/file?file=' . $img. '"  />';

}

This code works fine for the cliente profile. But now i am trying to display all users in my admin painel.

This way ...

function display_all_logo(){
    global $conn;

    $stmt = $conn->prepare("SELECT * LogoImage FROM usuarios");

    // $stmt = $conn->prepare("SELECT  LogoImage FROM usuarios WHERE nome=?");
    // $stmt->bind_param("s", $em);
    // $em = $_SESSION['userName'];
    $stmt->execute();
    $stmt->bind_result($LogoImage);

     while($stmt->fetch()) {
        $tmp = array();
        $tmp["LogoImage"] = $LogoImage;


        array_push($LogoImage, $tmp);
    }

    $img =$rows['LogoImage']; 


echo '<img style="    margin-top: -14;
object-fit: contain;" src="includes/file?file=' . $img. '"  />';

}

i know that i'm doing something wrong, please someone help, long time that i don't program php.

Fixed

function display_all_logo($user_logo){
    global $conn;

     $stmt = $conn->prepare("SELECT LogoImage FROM usuarios WHERE  logoImage = ?  ");


    $stmt->bind_param("s", $em);
    $em = $user_logo;
    $stmt->execute();

    $result = $stmt->get_result();
    $rows = $result->fetch_assoc();

    $img =$rows['LogoImage']; 


return '<img style="    margin-top: -14;
object-fit: contain;" src="includes/file?file=' . $img. '"  />';

}
  • 写回答

2条回答 默认 最新

  • dtz63853 2017-06-05 14:16
    关注

    Your should select the column name

     $stmt = $conn->prepare("SELECT LogoImage FROM usuarios");
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看