Heim > Backend-Entwicklung > PHP-Tutorial > 表单查询不到值。

表单查询不到值。

WBOY
Freigeben: 2016-06-23 13:27:08
Original
791 Leute haben es durchsucht

如下代码

<?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>待签核</h2></font></center>     "; }elseif($listkind=='LM'){        echo "      <big><center><font color=crimson><h2>草稿/退件</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);?>
Nach dem Login kopieren

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


回复讨论(解决方案)

看看你实际执行的 SQL 指令

看看你实际执行的 SQL 指令


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

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

谢谢两位,结贴。

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage