Why is my if statement not working the way I expect?

前端 未结 2 1095
情话喂你
情话喂你 2021-01-29 07:11

I am trying to achieve the following: I ask my SQL database a query using SELECT * FROM subjects. After doing that I ask for the array using mysqli_fetch_asso

相关标签:
2条回答
  • 2021-01-29 07:53

    In if statement you should use double equal sign: if (a == b)

    0 讨论(0)
  • 2021-01-29 08:01

    Your comparison operator is wrong. You're using = which is an assignment operator. In your example it will always be true. You need to use == which is a comparison operator.

    if ($subject["sexo"] = 1) { 
    

    should be

    if ($subject["sexo"] == 1) { 
    
    0 讨论(0)
提交回复
热议问题