循环中的多个mysqli prepare语句不起作用

时间:2019-03-23 19:09:56

标签: php mysqli

这是我遇到问题的代码,在这里我无法获得stmt2提取数据的任何结果,

$result = $user_hash_conn->query($q1);
    if($result->num_rows > 0){
        $stmt = $store_conn->prepare('SELECT `location`,`institute`, `category`, `sub_category`, `date`,`title`, `message` FROM `pre_demand_by_key` WHERE `key`=?');
        $stmt->bind_param("s",$key);

        # for no of match found 
        $stmt2 =  $store_conn->stmt_init();
        $stmt2 = $store_conn->prepare('SELECT `key` FROM `store_list` WHERE `location`=? AND `institute` LIKE ? AND `category`=? AND `sub_category` LIKE ?');



        while($row = $result->fetch_assoc()){

            $key = $row['varchar_128'];

            $stmt->execute();

            $stmt->bind_result($location,$institute,$category,$sub_category,$date,$title,$message);

            while($stmt->fetch()){

                #no of match found 
                $location2 = $location;
                $institute2 = $institute."%";
                $category2 = $category;
                $sub_category2 = $sub_category."%";

                $stmt2->bind_param("ssss",$location2,$institute2,$category2,$sub_category2);

                $stmt2->execute();
                $stmt2->bind_result($item_key2);
                echo $stmt2->error;
                $item_keys = [];
                while($stmt2->fetch()){
                    echo $item_key2;
                }



            }

        }

    }

我在表中记录了我的第二个stmt,但是当我手动执行时,在这里我没有给出任何结果,所有代码都正确编写了(意味着我没有与db或tb名称有关的拼写错误)在phpmyadmin上检查它,它返回了一些结果。请帮我。我在过去4到5个小时内一直在努力处理自己的代码

0 个答案:

没有答案