Let’s see...
As a general rule, when inserting HTML elements through PHP, you should always:
1 - Use double escaped quotes for element attributes. To escape the quotes, simply put the backslash before it will be interpreted as a character of the string and not string delimiting. Example:
<?php
echo "<div class=\"minha_classe\"></div>";
// Resulta no HTML <div class="minha_classe"></div>
?>
2 - If you need to use single quotes for some internal string of the attribute - as in the case of a Javascript string of a function in some on attribute (onclick, onblur...) - there will be no conflict if you followed what is found in 1. Example:
<?php
// Forma sem conflito:
echo "<div onclick=\"alert('teste');\"></div>";
// Resulta no HTML <div onclick="alert('teste');"></div>
?>
<?php
// Forma com conflito:
echo "<div onclick='alert('teste');'></div>";
// Resulta no HTML <div onclick='alert('teste');'></div>
?>
By following these rules, you can easily concatenate strings in PHP to take advantage of the values of the variables without errors. There will be no conflict be done correctly.
Your code
I gave a "slap" in your code to better understand what was done. This way, it is easier to avoid affecting errors. Consequently, removed any possible error.
You can change or rearrange variables and their names in any way you like. There is no single way to organize. But it’s important to be organized!
<?php
if( $dados_login["acesso"] >= 3 ){
// Construção dos argumentos de window.open(...)
$uarg = "id=" . $id . "&perfil=1&nome_aps=" . $dados_APS['nome_aps'];
$url = "icg_historico_excluidos.php?" . $uarg;
$name = "";
$spec = "height=690,width=1050,top=90,left=500,scrollbars=yes,resizable=no";
// Argumentos completos de window.open(...)
$fargs = "'" . $url . "', '" . $name . "', '" . $spec . "'";
// HTML completo
echo "<div class=\"col-md-2\">";
echo "<button type=\"button\" onclick=\"window.open(" . $fargs . ");\" ";
echo "class=\"btn btn-block btn-warning\">";
echo "Histórico da Exclusão de ICG";
echo "</button>";
echo "</div>";
}
?>
It is worth noting that if there are quotes in the variables used, it may cause some conflict. Then the recommendation is pay close attention and plan well the way it will join all quotes, considering all text sources and its possible content! ]
That is: make sure the content of $dados_APS['nome_aps']
because it can cause conflict. And happy hacking!
Hello Jennifer, so that people can help you and better understand your problem I recommend you copy a larger part of the code with the critical points and use the code marking in the Question editor. I recommend this link.
– Augusto A