fai una cosa del genere :
codice:<?php $query = "SELECT * FROM tab_articolo"; $where = array(); if(isset($_POST['titolo'])){ $where[] = "articoli.articolo_titolo LIKE '%" . $var . "%'"; } if(isset($_POST['testo'])){ $where[] = "articoli.articolo_testo LIKE '%" . $var . "%'"; } if(count($where) > 0){ if(isset($_POST['allwords'])) $s = ") AND ("; else $s = ") OR ("; $query .= " WHERE (".implode($s,$where).")"; } echo $query;