I want to view records based on the selected drop down value so I used sql query with WHERE clause. When I echo that query, it is fetching the drop down value which I selects but it isn't showing me the records in the table. When I give the values in Where clause on my own like e.g. WHERE name='John', It shows me the record of John but when I write WHERE name='$select' and echo it, It fetches the selected value i.e. name=John in query but don't show the records. Here is my code:
$con=mysqli_connect("localhost","root","","project_db");
if(mysqli_errno($con))
{
echo "Can't Connect to mySQL:".mysqli_connect_error();
}
$select1=isset($_POST['select1']) ? $_POST['select1'] : '';
$select2=isset($_POST['select2']) ? $_POST['select2'] : '';
$select3=isset($_POST['select3']) ? $_POST['select3'] : '';
$select4=isset($_POST['select4']) ? $_POST['select4'] : '';
echo $sql = "SELECT * FROM projecttbl WHERE $select1= '".$select2."' AND $select3='".$select4."'";
$result = mysql_query($con,$sql);