时间:2021-07-01 10:21:17 帮助过:3人阅读
  可以这么写  
  
$where = array();if($sel_key10){$where[] =" cu.province ";  // 省}if($sel_key11){$where[] =" cu.KFName";  // 客户名称}if($sel_key12){$where[] = " cu.GiveGasTime ";  // 通气时间 }$MYSQL->query("select * from customer cu " . (!empty($where) ? 'order by '. implode(',',$where) : '');  测试代码
 'cu.province', // 省  'sel_key11' => 'cu.KFName', // 客户名称  'sel_key12' => 'cu.GiveGasTime', // 通气时间 );$sql = "select * from customer cu ";if($_POST) {  $t = array_intersect_key($dict, $_POST);  if($t) $sql .= 'order by ' . join(', ', $t);}echo $sql;  如果改造一下表单,处理起来更简单
如果改造一下表单,处理起来更简单
容易产生sql注入漏洞, 慎用#1 ,#2 ,的方法都没成功, #3 版主的方法成功了。谢谢。