search
HomeBackend DevelopmentPHP Tutorial表单查询不到值。

如下代码

<?require('common.inc') ;show_user($ID);require('/php/acc/invoice/fun_list.inc');//require('list.inc');  //==========权限控制$size=3;        #表格中字体大小if($position=='') $position=0;if(!$page_row)$page_row=20;   #每页显示数据笔数//==================搜索方式确定==========================//echo    '<meta http-equiv="Content-Type" content="text/html" charset="gb2312">'.   '<LINK rel="stylesheet" type="text/css" href="//w3.yungtay.com.cn/sample/newform.css">'.   '<title>收据列表</title>'.   '<form ENCTYPE=multipart/form-data name=query_out action=acc_invoice_list.php>'.   '<body vlink=blue link=indigo>';   "<input type=hidden name=listkind value='$listkind'>   <input type =hidden id = sheet_no  value='$sheet_no'>   <input type =hidden id = contract_no  value='$contract_no'>   ";if($listkind=='LU')  {      echo "      <big><center><font color=crimson><h2 id="待签核">待签核</h2></font></center>     "; }elseif($listkind=='LM'){        echo "      <big><center><font color=crimson><h2 id="草稿-退件">草稿/退件</h2></font></center>     "; }if($listkind=='ALL')  {     echo "           申请单号:<input type=text name=sheet_no size=10 maxlength=10>         申请人:<input type=text name=create_user size=5 maxlength=5>		 合约号:<input type=text name=contract_no size=10 maxlength=20>         <br>		 是否结案:  <select name=action_code><option value='$action_code'>                        <option value='Z'>已结案                        <option value='W'>未结案                        <option value=''>				     </select>        申请日期段:<input type=text name=s_date size=10 maxlength=10>-<input type=text name=e_date size=10 maxlength=10>             <input type=submit value=搜索>         <br><br>		 ";   }//申请开始日期作为查询条件  if($s_date!=''){      $create_dates1=" and trunc(a.create_date)>='$s_date' ";	}else{     $create_dates1=""; 	}//申请结束日期作为查询条件  if($e_date!=''){      $create_dates2=" and trunc(a.create_date)<='$e_date' ";   }else{     $create_dates2=""; }//是否结案作为查询条件if($action_code=='W'){      $action_codes=" and b.flow_code not like 'Z%' ";   }elseif($action_code=='Z'){       $action_codes=" and b.flow_code like 'Z%' ";   }else{     $action_codes=" ";  }//查询条件的类型if($listkind=='LM' or $listkind=='LU' ){     $c_from=",subflow c ";     $c_where="and  a.form_key=c.form_key"; 	}else{ 	     $c_from=" ";     $c_where=" ";}//查询条件的类型if($listkind=='LM') //退稿件{       $current_code="and c.current_user='$ID'  and a.creator='$ID'";}elseif($listkind=='LU'){   //待签核稿件      $current_code="and c.current_user='$ID' and a.creator<>'$ID' and b.flow_code<>'Z'";}else{      $current_code=""; 	  }		   $where="where  a.form_key=b.form_key  $c_where and  a.creator like '$create_user%'           and a.sheet_no like '$sheet_no%'          $create_dates1 $create_dates2 $action_codes $current_code";//acc_invoice为主表  查询数据总数	 $sel="select count(distinct a.sheet_no)       from acc_invoice a,flow b $c_from	  	  	  	  $where";$stmt=$dbh->prepare("$sel");$stmt->execute()||die("sel error");list($count_num)=$stmt->fetch();//空数据的提示if($count_num<1)  {      echo "     <P ALIGN=\"center\"><FONT COLOR=crimson size=18>无可查询文件	 <BR><A HREF=http://w3.yungtay.com.cn target=_parent>回首页 </A></FONT>";	 exit(); 	 }//输出表单echo "<table border=0 width=100%>      <tr align=center>      <th><font color=white>申请单号          <th><font color=white>帐套      <th><font color=white>合约号      <th><font color=white>金额           <th><font color=white>签核者	  <th><font color=white>签核日期	  <th><font color=white>操作	  </tr>	  ";$variable="$PHP_SELF?listkind=CQ&query=$query";//表单数据查询并取出数据$d_field="distinct a.sheet_no,a.creator,a.create_date,b.flow_code,          a.form_key,a.account_city,a.contract_no,a.par_value,is_print";	  $sel="select * from (select tt.*,rownum as rn                       from (select $d_field                               from acc_invoice a,flow b $c_from                             $where order by a.sheet_no desc) tt                      where rownum<=($page_row+$position))              where rn>$position";			  $stmt=$dbh->prepare("$sel");$stmt->execute()||die("sel error");$i=0;while(list($sheet_no,$creator,$create_date,$flow_code,$form_key,$account_city,$contract_no,$par_value,$is_print)=$stmt->fetch())   {      $selc="select current_user from subflow where form_key='$form_key'";      $stc=$dbh->prepare("$selc");      if($stc->execute())        {		list($current_user)=$stc->fetch(); 		}      $creator_name=name($creator);      $current_name=name($current_user);      $dept_name=get_depart_name($dept_no);	  	  /*      if($flow_code=='2') //==签核时抓取签核人员        {          $sql_str="select a.current_user,name(a.current_user)                    from subflow a,flow b                    where a.form_key=b.form_key and b.form_key='$form_key'                          and a.current_user='$ID'                          order by a.form_key,a.seq";		  //echo $sql_str;          $stmt_str=$dbh->prepare("$sql_str");          $stmt_str->execute()||die("sql_str error");          		  while(list($c_user,$c_user_name)=$stmt_str->fetch())               {                 $size=2;                 if($current_names=='') 				 { 				    $current_names=$c_user.$c_user_name; 				 }else{				    $current_names=$current_user.'-'.$current_name; 				 }               }        }else */		if($current_user=='00000' and $flow_code=='Z'){ 		     $size=''; 			 $current_names='结案'; 	    }else{ 		     $size=''; 			 $current_names=$current_user.'-'.$current_name; 	    }       if($i==0 or $i%2==0){	      $setcolor="line1";	   }else{	      $setcolor="line9";	   }	   	   if($is_print==1){	   	$oper="已列印";	   }else{	   	$oper="无操作";	   }	   	  $account= get_account_city($account_city);	  $fpar_value= number_format($par_value,2,'.',',');	  if($listkind=='LM'){//退稿件      echo   "       <tr>	   <td align=center id=$setcolor><a href='http://oracle.yungtay.com.cn/acc/invoice/acc_invoice1_c.php?sheet_no=$sheet_no&listkind=$listkind&form_key=$form_key' target='_parent'>$sheet_no</a></td>       <td align=center id=$setcolor>$account</td>       <td align=center id=$setcolor>$contract_no</td>       <td align=center id=$setcolor>$fpar_value</td>       <td align=center id=$setcolor>$current_names</td>	   <td align=center id=$setcolor>$create_date</td>	   <td align=center id=$setcolor><a href='http://oracle.yungtay.com.cn/acc/invoice/delete.php?sheet_no=$sheet_no'>删除</a></td>	   </tr>	   ";	   }else{	   echo   "       <tr>	   <td align=center id=$setcolor><a href='http://oracle.yungtay.com.cn/acc/invoice/acc_invoice1_c.php?sheet_no=$sheet_no&listkind=$listkind&form_key=$form_key' target='_parent'>$sheet_no</a></td>       <td align=center id=$setcolor>$account</td>       <td align=center id=$setcolor>$contract_no</td>       <td align=center id=$setcolor>$fpar_value</td>       <td align=center id=$setcolor>$current_names</td>	   <td align=center id=$setcolor>$create_date</td>	   <td align=center id=$setcolor>$oper</td>	   </tr>	   ";	   	   	   	   }	          $i=$i+1;	      }echo "</form></table>";//分页数据query_list($count_num,$page_row,$position,$variable);?>

在页面上,点击查询之后查不到合约号,就是按合约号查询的时候查不到条件的合约号,如查询合约号等于1的部分,点击查询之后查到的却是所有数据,求大神帮忙!


回复讨论(解决方案)

看看你实际执行的 SQL 指令

看看你实际执行的 SQL 指令


版主,sql命令不是上边代码有写么。。。你说的是后台处理之后的sql语句么?

数据库中是否有记录?
先在db中直接执行sql看看。
然后再看代码生成的sql是否有错。

谢谢两位,结贴。

Statement
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
11 Best PHP URL Shortener Scripts (Free and Premium)11 Best PHP URL Shortener Scripts (Free and Premium)Mar 03, 2025 am 10:49 AM

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Introduction to the Instagram APIIntroduction to the Instagram APIMar 02, 2025 am 09:32 AM

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Working with Flash Session Data in LaravelWorking with Flash Session Data in LaravelMar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

Build a React App With a Laravel Back End: Part 2, ReactBuild a React App With a Laravel Back End: Part 2, ReactMar 04, 2025 am 09:33 AM

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Simplified HTTP Response Mocking in Laravel TestsSimplified HTTP Response Mocking in Laravel TestsMar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

cURL in PHP: How to Use the PHP cURL Extension in REST APIscURL in PHP: How to Use the PHP cURL Extension in REST APIsMar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

12 Best PHP Chat Scripts on CodeCanyon12 Best PHP Chat Scripts on CodeCanyonMar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Announcement of 2025 PHP Situation SurveyAnnouncement of 2025 PHP Situation SurveyMar 03, 2025 pm 04:20 PM

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MinGW - Minimalist GNU for Windows

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.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment