Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在会话php数组中显示下一条记录_Php_Mysql_Arrays_Session_Next - Fatal编程技术网

在会话php数组中显示下一条记录

在会话php数组中显示下一条记录,php,mysql,arrays,session,next,Php,Mysql,Arrays,Session,Next,我试图在会话变量中输出结果,该变量是使用echo current和echo next从SQL查询中填充的。但是,屏幕上不会回响任何文本 用于获取数据并放入数组的SQL语句 $SQL=“从属性特征中选择*,其中pf\u pr\u ID=3”; $result=$conn->query($SQL); $\会话[arrProperty\u Features]=$result->fetch\u assoc() 尝试回显数组中的第一项(当前) 试试下面的代码,我想你会得到想要的结果。php当前或下一个函

我试图在会话变量中输出结果,该变量是使用
echo current
echo next
从SQL查询中填充的。但是,屏幕上不会回响任何文本

用于获取数据并放入数组的SQL语句

$SQL=“从属性特征中选择*,其中pf\u pr\u ID=3”;
$result=$conn->query($SQL);
$\会话[arrProperty\u Features]=$result->fetch\u assoc()

尝试回显数组中的第一项(当前)


试试下面的代码,我想你会得到想要的结果。php当前或下一个函数处理的是单个数组而不是多维数组。通过fetch_assoc()您将获得多维数组

<?php
    while($row = $result->fetch_assoc()) {
        $_SESSION['arrProperty_Features'][] = $row;
    }

    ?>
    <!--Attempt to echo first item in the array-->
    <p><input class="w3-input" name="txtFeature1" type="text" id="txtFeature1" value="<?php echo $_SESSION['arrProperty_Features'][0]['pf_Feature'];?>"><br>

    <!--Attempt to echo second item in the array !-->
    <p><input class="w3-input" name="txtFeature1" type="text" id="txtFeature2" value="<?php echo $_SESSION['arrProperty_Features'][1]['pf_Feature'];?>"><br>


试试下面的代码,我想你会得到想要的结果。php当前或下一个函数处理的是单个数组而不是多维数组。通过fetch_assoc()您将获得多维数组

<?php
    while($row = $result->fetch_assoc()) {
        $_SESSION['arrProperty_Features'][] = $row;
    }

    ?>
    <!--Attempt to echo first item in the array-->
    <p><input class="w3-input" name="txtFeature1" type="text" id="txtFeature1" value="<?php echo $_SESSION['arrProperty_Features'][0]['pf_Feature'];?>"><br>

    <!--Attempt to echo second item in the array !-->
    <p><input class="w3-input" name="txtFeature1" type="text" id="txtFeature2" value="<?php echo $_SESSION['arrProperty_Features'][1]['pf_Feature'];?>"><br>


“$result->fetch_assoc()”不会一次给出所有结果。不断迭代它,直到它为您提供NullThank Tarun-我已经尝试过了,但它似乎陷入了一个永恒的循环中,$result=$conn->query($SQL)){$\u SESSION[arproperty\u Features]=$result->fetch\u assoc();}“$result->fetch\u assoc()”不会一次给出所有结果。不断迭代它,直到它给你一个空值——我已经尝试过了,但它似乎陷入了一个永恒的循环,而($result=$conn->query($SQL)){$\u SESSION[arrperty\u Features]=$result->fetch\u assoc();}