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>';
}
得到where子句
最新推荐文章于 2024-08-09 22:54:40 发布