Advertisement
cdsatrian

IN clause

Aug 19th, 2013
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. //...
  2.   $in_field=array('stswaranty','stscontractfull','stscontractsoft','stscontracthard','stsnoncon');
  3.   $in_array=array();
  4.   foreach($in_field as $inf){
  5.     if(!empty($_POST[$inf]))
  6.       $in_array[]=$_POST[$inf];
  7.   }        
  8.   $query = "SELECT s.datecreated, c.CustomerName, s.descissue, s.statusjobs, "
  9.           ."       s.status, s.dateofissue, s.visitdate, s.picoutlet, s.picoutlettel "
  10.           ."FROM support s "
  11.           ."INNER JOIN customer c ON s.outletid=c.CusID "
  12.           ."WHERE 1=1 "
  13.           .(!empty($_POST['attendedname'])?" AND s.attendedname='{$_POST['attendedname']}'":"")
  14.           .((!empty($_POST['rfromdate']) && !empty($_POST['rtodate']))?" AND s.datecreated BETWEEN '{$_POST['rfromdate']}' AND '{$_POST['rtodate']}'":"")
  15.           .(count($in_array)>0?" AND s.status IN('".implode("','",$in_array)."')";
  16.  $sql=mysql_query($query);
  17.  echo $query;
  18. //...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement