0

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);
2
Contributors
3
Replies
39
Views
2 Months
Discussion Span
Last Post by rproffitt
0

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

0

@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.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.