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

前端 未结 2 1138
情话喂你
情话喂你 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 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) { 
    

提交回复
热议问题