背景:在一ldt.php页面中有同一个form,两个按钮分别在提交的时候给到两个不同页面。一个按钮是插入数据库,一个按钮是查询并提交给自己在本页中展示出结果内容,有分页函数,提交后跳转过来的第一页是正常显示查询条件对应的结果的,但是点击下一页等就会显示数据库全部结果。我觉得应该是分页的时候没有带上参数,但是不知道怎么带,把部分源代码贴上来,请大神修改一下。
1、js提交不同页面:
<script></script>
<script> <br /> function submitit1() <br /> //交由程序1处理 <br /> { <br /> document.myForm.action = "其他.php" <br /> document.myForm.submit(); <br /> } <br /> function submitit2() <br /> //交由本页处理 <br /> { <br /> document.myForm.action = "ldt.php" <br /> document.myForm.submit(); <br /> <br /> } <br /> </script>
2、分页函数:
$page = $_GET["page"];
function Page($rows,$page_size){
global $page,$select_from,$select_limit,$pagenav;
$page_count = ceil($rows/$page_size);
if($page if($page >= $page_count) $page = $page_count;
$select_limit = $page_size;
$select_from = ($page - 1) * $page_size.',';
$pre_page = ($page == 1)? 1 : $page - 1;
$next_page= ($page == $page_count)? $page_count : $page + 1 ;
$pagenav .= "第 $page/$page_count 页 共 $rows 条记录 ";
$pagenav .= "首页 ";
$pagenav .= "前一页 ";
$pagenav .= "后一页 ";
$pagenav .= "末页";
$pagenav.=" 跳到
回复讨论(解决方案)
你贴出的两段代码,基本与解决问题无关
你只需要用某种方法保存下查询时的筛选条件就可以了
保存后赋给谁呢
include 'tof3/header.php'; $_SESSION['hcrdtbj']=$_GET['hcrdtbj'];
$hcrdtbj=$_SESSION['hcrdtbj'];
?>
nbsp;HTML>
<script></script>
<script> <br /> function submitit1() <br /> //交由程序1处理 <br /> { <br /> document.myForm.action = "hcoutinsert.php" <br /> document.myForm.submit(); <br /> } <br /> function submitit2() <br /> //交由程序2处理 <br /> { <br /> document.myForm.action = "ldt.php" <br /> document.myForm.submit(); <br /> <br /> } <br /> </script>
<script></script>
<script></script>
<script><!-- <br /> $(document).ready(function(){ <br /> _w_table_rowspan("#spdata",2); <br /> <br /> }); <br /> // --> <br /> </script>
用户名 | 归属 | 场景 | 类型 | 明细 | 领用数 | 原因 | 操作人 | 时间 |
---|
<?phpinclude 'tof3/header.php'; $_SESSION['hcrdtbj']=$_GET['hcrdtbj'];$hcrdtbj=$_SESSION['hcrdtbj'];?><!DOCTYPE HTML><html><head> <meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"/><script type="text/javascript" ></script> <script> function submitit1() //交由程序1处理 { document.myForm.action = "hcoutinsert.php" document.myForm.submit(); } function submitit2() //交由程序2处理 { document.myForm.action = "ldt.php" document.myForm.submit(); } </script><script type="text/javascript" src="js/jquery-1.8.3.min.js" ></script><script type="text/javascript" src="js/tablespan.js" ></script><script type="text/javascript"><!-- $(document).ready(function(){ _w_table_rowspan("#spdata",2); }); // --> </script> <meta charset="utf-8"></head><BODY> <div id="main"><div id="top"><div id="headerborder"><div id="hl"></div><div id="hm"></div><div id="hr"><!--<span style="text-align:right;"> <input type="button" onmouseover="this.className='on1' " onmouseout="this.className='out1'" style="width:80px; height:40px; font-size:12px; font-family:'Microsoft YaHei UI'; border:1px solid #CDCDCD;" value="返回导航" /></span>--></div></div><!--移动设备--><div id="header"> <div id="header1"> <div id="inheader11">领用详情</div><div id="inheader1" onclick="location.href='rdt.php'" style="cursor:pointer;"><a style="color:#999;">库存详情</a></div> </div> <form name="myForm" method="post"><div id="header2"></div><div id="header"><div id="inheader22"><div id="inheader23"> <input name="customer" style=" width:80px; vertical-align:middle;" value="用户名" id="userChooser" class="oc_common oc_userchooser" > <select id="scene" name="scene" style="vertical-align:middle;" ></select> <select id="purpose" name="purpose" style="vertical-align:middle;"></select> <select id="catalogue" name="catalogue" style="vertical-align:middle;"> </select> <select id="hc" name="hc" style="vertical-align:middle;"> </select><script type="text/javascript">addressInit('scene','purpose','catalogue','hc');</script> <input name="number" style=" width:60px; vertical-align:middle;" onkeyup="value=this.value.replace(/\D+/g,'')" value="数量" onfocus="this.value='';" onblur="if(this.value==''){this.value='数量'}" /> <select name="reason" style="vertical-align:middle;" > <option>原因</option> <option>新领</option> <option>更换</option> <option>借用</option> <option>测试</option> </select></div><div id="inheader24"><div id="inheader25"> <input name="mysubmit" type="button" value="领用" title="领用每项必填" onClick=submitit1() onmouseover="this.className='on1' " onmouseout="this.className='out1'" style="cursor:pointer;outline:none;width:40px; height:40px;border-radius:50%; font-size:12px; vertical-align:middle; font-family:'Microsoft YaHei UI'"/></div><div id="inheader25"> <input name="mysubmit" type="button" value="查询" title="查询条件忽略数量" onClick=submitit2() onmouseover="this.className='on1' " onmouseout="this.className='out1'" style="cursor:pointer;outline:none;width:40px;height:40px; border-radius:50%;font-size:12px; vertical-align:middle; font-family:'Microsoft YaHei UI'"/> </div> <div id="inheader25"> <input name="导出" type="button" value="导出" title="导出当前页面内容" onclick="location.href='exportl.php' " onmouseover="this.className='on1' " onmouseout="this.className='out1'" style=" cursor:pointer;outline:none; width:40px; height:40px;border-radius:50%;vertical-align:middle; font-size:12px; font-family:'Microsoft YaHei UI'" /> </div></div></div></div></form> </div></div><div id="m"><table id="spdata" align="center" width="800px" border="0px" ><th style="width:140px;">用户名</th><th style="width:55px;">归属</th><th style="width:55px;">场景</th><th style="width:90px;">类型</th><th style="width:110px;">明细</th><th style="width:40px;">领用数</th><th style="width:50px;">原因</th><th style="width:100px;">操作人</th><th style="width:160px;">时间</th><?php $page = $_GET["page"]; function Page($rows,$page_size){ global $page,$select_from,$select_limit,$pagenav; $page_count = ceil($rows/$page_size); if($page <= 1 || $page == '') $page = 1; if($page >= $page_count) $page = $page_count; $select_limit = $page_size; $select_from = ($page - 1) * $page_size.','; $pre_page = ($page == 1)? 1 : $page - 1; $next_page= ($page == $page_count)? $page_count : $page + 1 ; $pagenav .= "第 $page/$page_count 页 共 $rows 条记录 "; $pagenav .= "<a href='?page=1&hcrdtbj=$_SESSION[hcrdtbj]'>首页</a> "; $pagenav .= "<a href='?page=$pre_page&hcrdtbj=$_SESSION[hcrdtbj]'>前一页</a> "; $pagenav .= "<a href='?page=$next_page&hcrdtbj=$_SESSION[hcrdtbj]'>后一页</a> "; $pagenav .= "<a href='?page=$page_count&hcrdtbj=$_SESSION[hcrdtbj]'>末页</a>"; $pagenav.=" 跳到<select name='topage' size='1' onchange='window.location=\"?page=\"+this.value+\"&hcrdtbj=$_SESSION[hcrdtbj]\"'>\n"; for($i=1;$i<=$page_count;$i++){ if($i==$page) $pagenav.="<option value='$i' selected>$i</option>\n"; else $pagenav.="<option value='$i'>$i</option>\n"; } } // Page分页函数 // 使用示例 if (!$conn= mysql_connect("localhost", "r12" ,"22222")) die('数据库选择失败!'); if (!mysql_select_db("ccccccc", $conn)) die('数据库选择失败!'); // 用Page函数计算出 $select_from 从哪条记录开始检索、$pagenav 输出分页导航$sqlv = "SELECTmax(dtime) as dtimeFROMhaocaiwhere scene='VIP耗材'ORDER BYdtime DESC "; $rstv = mysql_query($sqlv,$conn); $rowv=mysql_fetch_assoc($rstv);$sqlp = "SELECTmax(dtime) as dtimeFROMhaocaiwhere scene='普通耗材'ORDER BYdtime DESC "; $rstp = mysql_query($sqlp,$conn); $rowp=mysql_fetch_assoc($rstp);//任意条件查询组合if(!empty($hcrdtbj)) { if(strstr($hcrdtbj,"VIP耗材")) { $hcr=substr($hcrdtbj, 9); $scener=mb_substr($hcrdtbj, 0, 5, 'utf-8'); } else { $hcr=substr($hcrdtbj,12); $scener=mb_substr($hcrdtbj, 0, 4, 'utf-8'); } $a="where scene='$scener' and hc='$hcr'";$_SESSION['where']= "where scene='$scener' and hc='$hcr'";}else{if($_POST['customer']=="用户名" && !empty($_POST['scene']) && !empty($_POST['purpose'])&& !empty($_POST['catalogue'])&& !empty($_POST['hc'])&& $_POST['reason']!=="原因"){ $a="where scene='$_POST[scene]' and purpose='$_POST[purpose]' and catalogue='$_POST[catalogue]' and hc='$_POST[hc]' and reason='$_POST[reason]'"; $_SESSION['where']="where scene='$_POST[scene]' and purpose='$_POST[purpose]' and catalogue='$_POST[catalogue]' and hc='$_POST[hc]' and reason='$_POST[reason]'"; $_SESSION['hcrdtbj']="$_POST[scene]$_POST[purpose]$_POST[catalogue]$_POST[hc]$_POST[reason]"; } else{ $a=""; $_SESSION['where']="order by dtime desc"; } }$rows = mysql_num_rows(mysql_query("select customer,scene,purpose,catalogue,hc,number,reason,person,dtime from haocai $a ")); Page($rows,35); $sql = "select customer,scene,purpose,catalogue,hc,number,reason,person,dtime from haocai $a order by scene,dtime desc limit $select_from $select_limit "; $rst = mysql_query($sql); while($row=mysql_fetch_assoc($rst)){ $vip_style = $row['scene']=="VIP耗材" ? ' style=" background-color:#096;color:white;"' : '';echo "<tr><td $vip_style>{$row['customer']}</td><td $vip_style>{$row['scene']}</td><td $vip_style>{$row['purpose']}</td><td $vip_style>{$row['catalogue']}</td>";if($row['scene']=="VIP耗材"){echo "<td $vip_style><a href='rdt.php?hcldtbj=$row[scene]$row[hc]' title='点击查看<$row[scene]/$row[hc]>的库存详情' style='color:white;'/a>{$row['hc']}</td>";}else{echo "<td $vip_style><a href='rdt.php?hcldtbj=$row[scene]$row[hc]' title='点击查看<$row[scene]/$row[hc]>的库存详情'/a>{$row['hc']}</td>";}echo "<td $vip_style>{$row['number']}</td><td $vip_style>{$row['reason']}</td><td $vip_style>{$row['person']}</td>";if($row['dtime'] ==$rowv['dtime'] || $row['dtime'] ==$rowp['dtime'] ) {echo "<td $vip_style>{$row['dtime']}<img src='pic/new.gif'/ alt="PHP查询提交给自身展示结果并分页为何点击下一页显示全部内容" ></td></tr>";}else{echo "<td $vip_style>{$row['dtime']}</td></tr>"; } } echo "<tr border=0><td colspan=9 align='right'>$pagenav</td></tr>";mysql_close($conn);mysql_free_result($rst);mysql_free_result($rstv);mysql_free_result($rstp); ?></table></div></div></body></html>

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version
Chinese version, very easy to use

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Atom editor mac version download
The most popular open source editor

Zend Studio 13.0.1
Powerful PHP integrated development environment