使用来自Mysql的获取数据并重用

时间:2017-06-01 09:10:20

标签: php mysql pdo

我需要使用此

中的获取数据
$employees=$user->viewEmployees();

使用

获取它
    <div style="position: relative;">
    <?php
     while ($employee = $employees->fetch()) { 
        $employee_name=$user->viewEmployeeUsingID($employee['id']);
        echo "<div id='div1' class='forDivision'>".$employee_name['employee_name']."</div>";
     } 
    echo "<div id='div1' id='forDivision' class='forDivision'>".$employee_name['id']."</div>";
     ?> 
  </div>

将对象$ employees重用到另一个whilelooping

<div style="position: relative; margin: 0px 0px 0px 200px; ">

    <?php
     while ($employee = $employee_winner->fetch()) { 
        $employee_name=$user->viewEmployeeUsingID($employee['id']);
        echo "<div id='div1' class='forLastname'>".$employee_name['employee_name']."</div>";

     } ?> 
    </div>

但错误说

Fatal error: Uncaught PDOException: SQLSTATE[IMSSP]: There are no more rows in the active result set. Since this result set is not scrollable, no more data may be retrieved. 

我所做的是使用另一个变量$ employees2,但我的主要dillema是我正在使用这个脚本(随机)查询生成器,所以会发生什么情况是查询没有生成一致的报告,任何想法或解决所需的?< / p>

$stmt = $this->conn->prepare("SELECT TOP 10 * FROM employees ORDER BY NEWID()");

0 个答案:

没有答案