0

I need to use the fetch data from this

$employees=$user->viewEmployees();

And fetch it using

    <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>

And reuse the object $employees to another 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>

But error says

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. 

What I did was to use another variable $employees2 but my main dillema is im using this script (Random) query generator, so what happen is the query is not generating a consistent report, any idea or work around that needed ?

$stmt = $this->conn->prepare("SELECT TOP 10 * FROM employees ORDER BY NEWID()");
Martney Acha
  • 2,802
  • 4
  • 33
  • 48

0 Answers0