The queries are made through mysqli prepared queries, the variable $previa
can bring two types of results yes
ornot
The query is performed by means of related data an example:
id articulo previa id_articulo
1 algo yes 2
2 algo1 yes 2
As can be seen, results are brought from the same id of the article.
And the results are the following:
something -> not something1 -> not
But it should be this way since in the database this data asyes
something -> yes something1 -> yes
Note: But if I get to change the value
yes
aroundnot
if it shows the result that it should show, but everything is being done backwards.
I am using the following code:
if($previa!="yes"){
echo $articulo;
echo 'yes';
} else {
echo $articulo;
echo 'not';
}
You have to take into account that the operator
!=
means other than .In your case, you are saying that if it is other than
yes
, that is,no
, displaynot
on screen and vice versa.You would have to change the operator of your
if
to perform a comparison.==
Double (or triple===
if you want an exact comparison) is used to indicate if a variable is equal to something .Your comparison would look like this:
Try this evaluation with ternary operators:
Output:
conclusion
This single line would suffice:
Or, if you want a
not
when is not yes, you change it to this:if yes is different from yes {echo $echo 'yes';}else {echo $article; echo 'not';}
is wrong if yes is the same as yes echo $article; echo 'yes'; else { echo $article; echo 'not';}