Hi, I am trying test a multiple criteria search with two text boxes. That is user will enter values in txt1 and txt2 (or) either one. I want to execute the Select query according to the txt1, txt2 values. If both are filled my 'where' condition will be like 'where txt1=$abc and txt2=$cde'. If anyone of the text box is empty (e.g. txt1 is empty) where condition will be 'where txt2=$cde'. I have tried this in php with mysql as backend. But getting 500 Internal Server Error. How to solve this.. I have added the code below <?php session_start(); $check=$_session['user']; $con = mysql_connect('localhost','my_user','my_pass'); mysql_select_db('project', $con); //Replace with your MySQL DB Name $txt1=$_POST['txt1']; $txt2=$_POST['txt2']; $sql ="select * from project_master where " if(!empty('$txt1')) { $sql .= "docno='$txt1' and "; } if(!empty('$txt2')) { $sql .= "itemno='$txt2' and "; } $sql = substr($sql,0,-4); \\ to knock off the last and $sql .= " order by `docno`"; while($result = mysql_fetch_array($sql)){ echo $result[7]; echo $result[3]; } ?> Code (markup):