PHP 不通过任何 if 语句,直接转到 else 语句


php doesn't pass through any of the if statement and goes directly to the else statement

有人可以告诉我这有什么问题吗,我认为我做对了一切,但我的返回值弹出了所有内容,这是我对最后一个 else 命令的命令,if 语句似乎不起作用...

<?php
$con=mysqli_connect("localhost","root","password","d_database");
if (mysqli_connect_errno($con)){
   echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$images = array();
if(isset($_GET['mydata']) )
    $mydata = $_GET['mydata'];
if(isset($_GET['category']) )
    $category = $_GET['category'];
if($category == 'Users'){
    $result = mysqli_query($con,"SELECT id, dish_name, dish_image, user_username FROM recipes WHERE user_username = '$mydata'");
}else if ($category == 'Recipes'){
    $result = mysqli_query($con,"SELECT id, dish_name, dish_image, user_username FROM recipes WHERE dish_name =  '$mydata'");
}else if ($category == 'Ingredients'){
    $result = mysqli_query($con,"SELECT id, dish_name, dish_image, user_username FROM recipes WHERE user_username =  '$mydata'");
}else{
    $result = mysqli_query($con,"SELECT id, dish_name, dish_image, user_username FROM recipes");
}
while($row = mysqli_fetch_assoc($result)){
    $images[] = $row;
}
echo "{images:".json_encode($images)."}";
mysqli_close($con);
?>

我在表单中使用了 POST 方法所以这就是为什么它是错误的... :(((

if(isset($_POST['mydata']) )
    $mydata = $_POST['mydata'];
if(isset($_POST['category']) )
    $category = $_POST['category']; 

解决我的问题