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);

Line 13 mysql_query() returns a resource. Not the actual items you are after. You're in luck though as the PHP manual which I'll link to shows how to get the items from your query.

Read http://php.net/manual/en/function.mysql-query.php

Specifically the example using this line in the manual at link above.
while ($row = mysql_fetch_assoc($result))

I have used that mysql_fetch_assoc below in the table but still it's not working

@Cara_1, I read your supplied code again even used a search and found no usage of mysql_fetch. You may want to share more code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.