0
Below follows the code and has a comment where I’m having trouble concatenating html + php... basic silly error but already merged the cuckoo and do not see the problem. thank you.
<?php
// Monta consulta MySQL para o gráfico
$sqlano = "SELECT DISTINCT YEAR(dateent) as Year FROM `cadastro`";
$queryano = $mysqli->query($sqlano);
?>
<form method="GET" action="" name="menuForm">
<header>
<h3>Relatório de pedidos por mês do ano de: </h3>
<select id="ano" name="ano" onchange="document.forms['menuForm'].submit();">
<option value="2000" disabled selected> Escolha o ano </option>
<?php
while($dadosano = $queryano->fetch_array()){
//essa linha abaixo estou com problema na concatenação mas já fundi a cabeça e não encontro o erro.
echo "<option value='".$dadosano['Year']."' ". isset($_GET['ano']) && $_GET['ano']== $dadosano['Year']?' selected="selected"' : ' ' ; " > ".$dadosano['Year']. "</option>";
}
?>
</select>
</header>
</form>
And what would that be
;
in the middle of the line, just after the ternary condition?– Woss
is to end the condition... condition ? code : code;
– Deadoc
Not only are you ending the condition, you’re ending your
echo
; everything after will give syntax error (probably the error you got and omitted in the question).– Woss
No error in execution but did not do what you have to do, popular select and take what was selected...
– Deadoc