得到where子句

	function where_str($arr) {
		$wstr = '';
		foreach ( $arr as $s1 ) {
			if(!$s1 [2]){$s1 [2]="1";}
			$name=$s1[0];
			$vl=trim($s1[1]);
			if($vl)
			switch ($s1 [2]) {
				case "1" ://包含
					$wstr .=  " and " . $name . " like '%" . $vl . "%'   ";
					break;
				case "2" ://等于
					$wstr .= " and " . $name . " = '" . $vl . "' ";
					break;
				
				case "3" ://大于
					$wstr .= " and " . $name . " > '" . $vl . "' ";
					break;
				case "4" ://小于
					$wstr .= " and " . $name . " < '" . $vl . "' ";
					break;
				case "5" ://大于等于
					$wstr .= " and " . $name . " >= '" . $vl . "' ";
					break;
				case "6" ://小于等于
					$wstr .= " and " . $name . " <= '" . $vl . "' ";
					break;
				case "7" ://不等于
					$wstr .= " and " . $name . " != '" . $vl . "' ";
					break;
				case "8" ://开始为
					$wstr .= " and " . $name . " like '" . $vl . "%' ";
					break;
				case "9" ://结束为
					$wstr .= " and " . $name . " like '%" . $vl . "' ";
					break;
			}
			
		}
		return $wstr;
	}
	
//输出查询条件字符串	
	 $fields=$this->cool_mdl->get_form_info();
		 foreach($sarr as $s){
			 if(!$s['type'] || $s['type']=="input"){
				$str='<input _name="'.$s['name'].'" size="10" class="input_txt" style="width:90px">';
			 }elseif($s['type']=="select"){
				 if(!$s['options']){
					$s['options']=$fields[$s['title']]['options'];
				 }
				 $s['options']="\r\n".trim($s['options']);
				 $s['other'].="_name='".$s['name']."'";
				$str=$this->form_mdl->form_select($s);
			 }elseif($s['type']=="between"){
				$str='<input _name="'.$s['name'].'" _type="5"  size="10" class="input_txt" style="width:70px" '.$s['other'].' /> - <input _name="'.$s['name'].'" _type="6"  size="10" class="input_txt" style="width:70px" '.$s['other'].' />';
				 
			 }
			 echo '<li> '.$s['title'].':'.$str.'</li>';
			 
		 }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值