1,"insert"=>2,"update"=>3,"delete"=>4); $show=FALSE; function make_sql($cate,$highlows,$item,$maker,$serial,$price){ $category = array("","item_deji","item_kaden","item_pc","item_ofice","item_cdvd"); $hg = array("<=",">="); $fr=FALSE; if($cate==0){ $table_all=TRUE; $table="TB"; }else{ $table=$category[$cate]; } $sql="select * from ".$table; if($item != NULL){ $fr=TRUE; $item=str_replace('กก',' ',$item); $buf=ereg_replace('[[:space:]]',"%' OR ITEM_NAME LIKE '%",$item); $sql = $sql." where "."ITEM_NAME LIKE '%".$buf."%' "; } if($maker != NULL){ if($fr){ $sql = $sql." AND "; }else{ $fr=TRUE; $sql=$sql." where "; } $maker=str_replace('กก',' ',$maker); $buf=ereg_replace('[[:space:]]',"%' OR ITEM_MAKER LIKE '%",$maker); $sql = $sql." ITEM_MAKER LIKE '%".$buf."%' "; } if($serial != NULL){ if($fr){ $sql=$sql." AND "; }else{ $fr=TRUE; $sql=$sql." where "; } $serial=str_replace('กก',' ',$serial); $buf=ereg_replace('[[:space:]]',"' OR ITEM_NUMBER = '",$serial); $sql = $sql."ITEM_NUMBER = '".$buf."' "; } if($price != NULL){ if($fr){ $sql=$sql." AND "; }else{ $fr=TRUE; $sql=$sql." where "; } $price=str_replace('กก',' ',$price); $buf=ereg_replace('[[:space:]]'," OR ITEM_PRICE $hg[$highlows] ",$price); $sql = $sql."ITEM_PRICE ".$hg[$highlows]." ".$buf." "; } /* if($fr){ $sql=$sql." AND "; }else{ $sql=$sql." where "; } $sql=$sql." ct <= 10"; */ if($table_all){ for($i=1;$i