搜索语句界面:
/*单一检索:此处为一个下拉列表的检索*/ if(isset($_POST[‘submit‘]) && $_POST[‘submit‘] == ‘点击搜索‘) { if(isset($_POST[‘content‘])) { $content = $_POST[‘content‘]; if (isset($_POST[‘basic‘])) { $basic = $_POST[‘basic‘]; $sql = "SELECT * FROM page WHERE $basic like ‘%$content%‘"; $result = mysqli_query($link, $sql); if ($result) { while ($row = mysqli_fetch_assoc($result)) { $page_info[] = $row; $tents[] = $row[‘id‘]; } } else { echo "未查询到数据"; } $_SESSION["n"]=$tents; //此处用session存储搜索到内容的id } } }
处理页面跳转的界面:
if(isset($_POST[‘prev‘]) && $_POST[‘prev‘] == ‘上一条信息‘) { if(isset($_POST[‘id‘])) { $id=$_POST[‘id‘]; $text = $_SESSION["n"]; //使用之前用session存储的搜索到的id $offset=array_search($id,$text); if($offset-1<0) { $prev=$id; echo "<script>alert(‘当前是第一条信息!‘);history.go(-1);</script>"; } else { $prev = $text[$offset-1];//上一条信息 header("location:../View/ShowDetail.php?id=$prev"); } } } if(isset($_POST[‘next‘]) && $_POST[‘next‘] == ‘下一条信息‘) { if(isset($_POST[‘id‘])) { $id=$_POST[‘id‘]; $text = $_SESSION["n"]; $num=count($text); $offset=array_search($id,$text); if($offset==$num-1) { $next=$id; echo "<script>alert(‘当前是最后一条信息‘);history.go(-1);</script>"; } else { $next = $text["$offset"+1]; header("location:../View/ShowDetail.php?id=$next"); } } }
时间: 2024-10-03 20:51:11