dongsu7049 2017-03-27 10:54
浏览 26

无法从数据库中获取图像和信息

I am trying to display image and details from database where i have stored. I have got code which connects to database but doesn't fetch. Edited: Thanks guys i was able to fetch but I have incurred anther problem. I have stored image as blob. so when i queried it displayed some mumbojumbo language. screenshot of the result screenshot of how i stored image ....... echo"Connected to db" ;

if (isset($_POST['info'])){
    $info= 'info';
    if ($info== 1){
        $sql= "SELECT name,img,price FROM product WHERE price<400";
        $result=mysqli_query($conn,$sql);
        while ($row = mysqli_fetch_assoc($result)){
            echo "<div class= 'row'>";
            echo    "<div class = 'col-sm-3'>";
            echo        "<p>".$row['img']."</p><br/>";
            echo        "<h3>".$row['name']."</h3><br/>";
            echo        "<h4>£".$row['price']."</h4><br/>";
            echo    "</div>";
            echo "</div>";
        }
    }

exit();

Here is my jquery code where it prints the the output of checkbox and it echo connected to database but can't fetch.

$(".id_price").each(function() {
if ($(this).is(":checked")) {
    var check = $(this).val();
    console.log(check);
    $.post('database.php',{info:check},function(response){
        $(".product").html(response).show(); 

    });

}

});

  • 写回答

2条回答 默认 最新

  • dongliuzhuan1219 2017-03-27 10:56
    关注
        echo"Connected to db" ;
    
    if (isset($_POST['info'])){
        $info= 'info'; // <----------------
        if ($info== 1){
            $sql= "SELECT name,img,price FROM product WHERE price<400";
            $result=mysqli_query($conn,$sql);
            while ($row = mysqli_fetch_assoc($result)){
                echo "<div class= 'row'>";
                echo    "<div class = 'col-sm-3'>";
                echo        "<p>".$row['img']."</p><br/>";
                echo        "<h3>".$row['name']."</h3><br/>";
                echo        "<h4>£".$row['price']."</h4><br/>";
                echo    "</div>";
                echo "</div>";
            }
        }
    
    exit();
    

    You set $info == "info" and then check if $info == 1

    Try this:

        .......
    echo"Connected to db" ;
    
        if (isset($_POST['info'])){
                    $sql= "SELECT name,img,price FROM product WHERE price<400";
                    $result=mysqli_query($conn,$sql);
                    while ($row = mysqli_fetch_assoc($result)){
                        echo "<div class= 'row'>";
                        echo    "<div class = 'col-sm-3'>";
                        echo        "<p>".$row['img']."</p><br/>";
                        echo        "<h3>".$row['name']."</h3><br/>";
                        echo        "<h4>£".$row['price']."</h4><br/>";
                        echo    "</div>";
                        echo "</div>";
    
                }
            }
            exit();
    
    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)