添加next按钮,显示使用PDO的特定记录的更多细节


Add next button showing more details of a specific record using PDO

我目前正在一个项目上工作,CRUD功能工作得很好,我几乎完成了,但只有一个问题,不能弄清楚如何做到这一点。我的问题是,我有一个更新按钮和更新功能的工作很好,当我点击更新按钮,它会一个特定的记录,我选择我的问题是,我想添加一个下一个按钮,这样当我点击下一个按钮,它会显示那个人的其他细节。因为在我的项目中有很多细节要包括,所以我需要一个下一个按钮,这样我就可以查看我选择的特定记录的其他细节。有人能帮我吗?

这是我的代码

class.user.php

public function dataview($query)
{
$stmt = $this->db->prepare("SELECT * from login ORDER BY username");
$stmt->execute();
if($stmt->rowCount()>0)
{
    while($row=$stmt->fetch(PDO::FETCH_ASSOC)) {
        echo "<tr>";
        echo "<td> ".$row['user_id']." </td>";
        echo "<td> ".$row['username']." </td>";
        echo '<td><a target="_blank" onclick="pop_up(this)" href=VIEWSAMPLE.PHP?user_id='.$row['user_id'].'>'.$row["username"].'</a></td>';
        echo "<td> ".$row['password']." </td>";
        echo '<td><a style="float:left" target="_blank" href="update.php?user_id=' .  $row["user_id"] . '>'.$row["username"].'"<input name="image" type="image" value="edit" onclick="pop_up(this)"><image src="image/EDIT.png" class="img-responsive" width="25px"></a>
        <a style="float:left" href="delete.php?user_id=' . $row["user_id"] . '>"<input name="image" type="image" value="delete" onclick="return confirm(''are you sure?'')"><image src="image/DELETE.png" class="img-responsive" width="25px"> </a></td>';
        echo "</tr>";
    }
}
else
{
    echo "<tr>";
        "<td>Nothing here...</td>";
        "</tr>";
}
}
}

这里是我的viewsample.php,我想添加一个下一个按钮

 <?php
 include_once 'dbconfig.php';
 $username = isset($_GET['username']) ? $_GET['username'] : '';
 $password = isset($_GET['password']) ? $_GET['password'] : '';
 $province = isset($_GET['province']) ? $_GET['province'] : '';
 if(isset($_GET['user_id']))
 {
     $user_id = $_GET['user_id'];
     extract($crud->getID($user_id));
 }
 ?>
 <body>
 <button onclick="this.style.display='none';document.body.offsetHeight;window.print();this.style.display='inline';">Print</button>
 <br />
 <br />
 <div id="Survey-view">
    <div id="header">
    </div>
 <p><strong>INFORMATION</strong></p>
        <hr />
            <div id="main-frame">
                <table id="information-content" cellspacing="0">
                    <thead>
                        <tr>
                            <th>Username</th>
                            <th>Password</th>
                            <th>Province</th>
                        </tr>
                    <tbody>
                        <tr>
                            <td><?php echo $username; ?></td>
                            <td><?php echo $password; ?></td>
                            <td><?php echo $province; ?></td>
                        </tr>
                    </tbody>
                    </thead>
                </table>
            </div>
        <br />
    <br />

在查询中,从数据库中获取下一个id

然后在viewsample.php文件中添加以下代码。

<a href="viewsample.php?user_id=id from database">Next</a>
viewsample.php中,根据$_GET['user_id']中传递的id获取数据

使用这个查询获取下一个id,

select * from table where id = (select min(id) from table where id > current id)