Reputation: 3777
I have a PHP echo value that displays a value from a MySQL database like this:
<?php echo($row_WADAHTG_TechProps["EmpType"]); ?>
I need to construct an if/else with this value but am getting a syntax error no matter how I try to arrange this:
<?php
if (echo($row_WADAHTG_TechProps["EmpType"]) = "6001") {
echo "Have a good day!";
} else {
echo "Have a good night!";
}
?>
Upvotes: 0
Views: 712
Reputation: 1941
($row_WADAHTG_TechProps["EmpType"] === "6001" ? echo "Yes" : echo "No");
Notice I'm strictly comparing $row_WADAHTG_TechProps["EmpType"]
to "6001" as strings, therefore if either of them are integers, the condition will echo "No"
.
Upvotes: 1
Reputation: 33
what about
<?php
if ($row_WADAHTG_TechProps["EmpType"] == "6001") {
echo "Have a good day!";
} else {
echo "Have a good night!";
}
?>
you have to compare a value with ==
or ===
(if you also want to compare the type)
Upvotes: 1
Reputation: 1316
if ( $row_WADAHTG_TechProps["EmpType"] == "6001") {
echo "Have a good day!";
} else {
echo "Have a good night!";
}
Careful with the single '=' sign in the if statement as that is an assignment.
Upvotes: 1
Reputation: 37233
try that:
<?php
if ($row_WADAHTG_TechProps["EmpType"] == "6001") {
echo "Have a good day!";
} else {
echo "Have a good night!";
}
?>
Upvotes: 2