我对编程很新。我正在尝试编写一个相当基本的if,ifif是我的数据库代码片段,但是当它编译时,它只是从第一个if语句一直打印到最后的代码。我已经过了好几天,无法解决我出错的地方
<!DOCTYPE html>
<html>
<body>
<?php
$row = "A1 Header";
$compulsary = FALSE;
$mutable = TRUE;
$included = FALSE;
if ($compulsary == FALSE and $mutable == TRUE) {
echo "<textarea style=background-color:yellow; name=\"message\">Please Enter</textarea><br>";
}
elseif ($compulsary == FALSE and $mutable == FALSE){
echo "'"$row"'";
}
elseif ($compulsary == True and $mutable == True) {
echo "<textarea style=background-color:yellow; name=\"message\">Please Enter</textarea><br>";
}
else {
echo "'"$row"'";
}
?>
</body>
</html>
答案 0 :(得分:0)
试试这个
<!DOCTYPE html>
<html>
<body>
<?php
$row = "A1 Header";
$compulsary = FALSE;
$mutable = TRUE;
$included = FALSE;
if ($compulsary == FALSE and $mutable == TRUE) {
echo "<textarea style=background-color:yellow; name=\"message\">Please Enter</textarea><br>";
} elseif ($compulsary == FALSE and $mutable == FALSE) {
echo "'".$row."'";
} elseif ($compulsary == True and $mutable == True) {
echo "<textarea style=background-color:yellow; name=\"message\">Please Enter</textarea><br>";
} else {
echo "'".$row."'";
}
?>
</body>
</html>
答案 1 :(得分:0)
You can do like this:
<!DOCTYPE html>
<html>
<body>
<?php
$row = "A1 Header";
$compulsary = FALSE;
$mutable = TRUE;
$included = FALSE;
if ($compulsary == FALSE and $mutable == TRUE) {
echo "<textarea style='background-color:yellow;' name='\"message\"'>Please Enter</textarea><br>";
}
elseif ($compulsary == FALSE and $mutable == FALSE){
echo $row;
}
elseif ($compulsary == TRUE and $mutable == TRUE) {
echo "<textarea style='background-color:yellow;' name='\"message\"'>Please Enter</textarea><br>";
}
else {
echo $row;
}
?>
</body>
</html>
答案 2 :(得分:-2)
我认为你有语法错误。试试这个:
echo "'\"$row\"'";