Home > Backend Development > PHP Tutorial > 怎么在switch语句内里面使用分页功能

怎么在switch语句内里面使用分页功能

WBOY
Release: 2016-06-13 11:11:29
Original
915 people have browsed it

如何在switch语句内里面使用分页功能?
我创建了一个表单

<form action = "query.php" method = "post" enctype = "multipart/form-data"><br />	选择查找类型: <br /><br />	<select name = "query"><br />		<option value = "name">name</option><br />		<option value = "address">address/option><br />	</select><br />	<br /><br />	输入查找内容: <br /><br />	<input type = "text" name = "query_text"  maxlength = "17"/><br />	<input type = "submit" value = "查找" /><br /></form><br />
Copy after login

在query.php页面选择的结构是:
switch ($_POST['query']){

case "name":
              此处查找数据库,并显示出来;
        case "address":
             此处查找数据库,并显示出来;
}

如何在[case "name"]与[case "address"]下查找数据库后显示加入分页功能啊?
由于分页浏览时,需要$_GET['page']来传递页数,但query.php页也有$_POST变量, 请问如何处理?麻烦指教


------解决方案--------------------
可以在query.php写个函数,把页数和查找类型作为参数传给函数。函数根据查找类型和页数查找每页的数据。然后在case后调用,或者在$_GET后调用。也可以在其他的php文件里写查找数据的函数,include进来,调用函数。$_POST不影响$_GET吧,你post过来肯定显示的是第一页把,可以把函数参数默认为第一页
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template