0
In the code, step to the variable $acesso
what would be the value extracted from the user’s session (just for testing). And I have 3 blocks of IF
, each checking different conditions for the same variable. But the three conditions are being met when only one is true.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Pagina inicial - Itiban pescados</title>
<!-- Bootstrap -->
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/custom.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<link rel="icon" href="/img/icon_boat2.png">
</head>
<body>
<div id="wrap">
<?php
///var/www/vhosts/pesca.itibanpescados.com.br/httpdocs
include("/check_1.php");
include("/header.php");
include_once("/config.php");
?>
<?php $acesso = 1;?>
<div class="row" style="margin:5px;"><legend><h1>Viagens em aberto</h1></legend></div>
<?php echo "Variavel acesso: " . $acesso; ?>
<br>
<div class="row" style="margin:5px;">
<table class="table table-striped">
<thead>
<tr>
<th>Viagem ID</th>
<th>Barco</th>
<th>Mestre</th>
<?php if (!isset($_SESSION['UsuarioID']) OR ($_SESSION['UsuarioNivel'] < 2)):else:?><th>Adiantamento</th><?php endif; ?>
<th>Data de saída</th>
<th>Data estimada de Entrada</th>
<th>Ocorrencia</th>
</tr>
</thead>
<?php //Exibe as viagens conforme o tipo de acesso do usuario
if($acesso==1){ ?>
<?php echo "ENTROU NO PRIMEIRO IF";?>
<?php}
if($acesso==2){?>
<?php echo "ENTROU NO SEGUNDO IF";?>
<?php}
if($acesso==3){?>
<?php echo "ENTROU NO TERCEIRO IF";?>
<?php } ?>
</table>
</div>
</div>
<?php include("/footer.php");?>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
<script src="js/append.js"></script>
<script src="js/append_venda .js"></script>
<!--<script src="js/checkform.js"></script>-->
</body>
</html>
change == to === (identico) and use If, dps comment if it worked.
– Diego Andrade
The problem is the lack of white space in
<?php}
. In this reply I explain about PHP tags, including the need to have this blank space.– Woss
@Diegoandrade, I used multiple Ifs to test merit, the original code is with elseif. But thanks for the help!
– Felipe Chagas