why my search code just show all data and dose not show the type result
<p>hi i created a search box and code in php but when i press on search it just show all evenwhen input is null, and when i change  it to a $query variable it shows the messeage that i define for not the infprmation  that dose not exit even when i type the name correct     </p>

<pre><code>if(isset($_POST['search']))
{

$searchg=$_POST['search'];

$searchg=preg_replace("#[^a-z0-9.]#i", "", $searchg);

$query="SELECT * FROM user WHERE uploadfilename LIKE '%$searchg%'";
$res=$con2-&gt;query($query);

$cont=mysqli_num_rows($res);
if($cont==0){
    $output="not such as information finds";
}

 else{


   while($row=mysqli_fetch_array($res,MYSQLI_BOTH)){
    $filename = $row['uploadfilename'];
    $conte = $row['content'];

    $output.='&lt;div&gt;'.$filename.'&lt;/div&gt;';
 }

}

}





   ?&gt;
</code></pre>