我是php的学习者,并希望在我的最后一年项目中得到一些帮助。从stackoverflow本身尝试过这种方法。但是'下一步'& “上一个”按钮似乎不起作用。请告诉我我做错了什么。请原谅我,如果这是重复但我无法从现有解决方案中检索解决方案。
这是我的代码:
<?php
session_start();
$connection= mysqli_connect('localhost','root','','test1');
if(mysqli_connect_errno())
{
echo "Error: ".mysqli_connect_errno();
}
?>
<?php
$qry=mysqli_query($connection,"select * from details");
$str=mysqli_fetch_array($qry);
$count=mysqli_num_rows($qry);
echo $id=$str['id'];
echo $tr=$id+$count-1; // total no. of questions selected from database
if(isset($_POST['next']))
{
$id=$id++;
$qry2=mysqli_query($connection,"select * from details where id='".$id."'");
$str2=mysqli_fetch_array($qry2);
$nm=$str['name'];
$ct=$str['city'];
}
if(isset($_POST['prev']))
{
$id=$id--;
$qry3=mysqli_query($connection,"select * from details where id='".$id."'");
$str3=mysqli_fetch_array($qry3);
$nm=$str['name'];
$ct=$str['city'];
}
?>
<html>
<body>
<center><br><br>
<table border="1px" height="75px" width="25%">
<tr> <th> Emp Name </th> <th> Emp city </th> </tr>
<form method="POST">
<tr> <td> <?php echo $str['name'] ?> </td> <td> <?php echo $str['city']?>
</td> </tr>
</table> <br><br>
<input type="button" name="next" value="Next">
<input type="button" name="prev" value="Prev">
</form>
</center>
</body>
</html>