dongtan6695 2016-08-11 06:29
浏览 35
已采纳

如何保存表回显到会话?

Here's my code:

now, how can I save these in session, so that whenever I go to new link, the table is still there. Thanks guys.

    while($row = mysqli_fetch_assoc($locate)){

            echo "<tr>";
            echo "<td>" . $row['id'] . "</td>";
            echo "<td>" . $row['name'] . "</td>";
            echo "<td>" . $row['grade'] . "</td>";
            echo "<td>" . $row['section'] . "</td>";
            echo "<td>" . $row['subject'] . "</td>";
            $namers = $row['name'];
            //echo "<td><center> <button name = 'name1' type = 'submit' value = '$namers'>Go</button> </center></td>";
  • 写回答

1条回答 默认 最新

  • dqz13288 2016-08-11 06:35
    关注

    Either store $row in a session:

    $_SESSION['rowdata'] = $row;
    

    OR serialise the $row to store it and unserialise it when you want to use it:

    //Store
    $_SESSION['rowdata'] = serialise($row);
    
    //get back
    $row = unserialise($_SESSION['rowdata']);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?