I have my javascript this way, that I create a pivot table:
var util = $('#utl4').val();
var linha = ``;
$.getJSON('./atman', function (data) {
var arrayLength = data.length;
for (var i = 0; i < arrayLength; i++) {
Id = data[i][0];
DataRegisto = data[i][1];
Destino = data[i][2];
Assunto = data[i][3];
Descricao = data[i][4];
nome = data[i][5];
colaborador = data[i][6];
linha += `<tr id=${ Id }>
<td>${ Id }</td>
<td>${ DataRegisto }</td>
<td>${ Destino }</td>
<td>${ Assunto }</td>
<td>${ Descricao }</td>
<td>${ nome }</td>
<td><?php if($colaborador == $util): ?><button type="button" data-target="#ad_man" class="btn btn-warning btn-sm edit_man" ><span class="glyphicon glyphicon-pencil"></span></button><?php endif; ?></td>
<td><?php if($colaborador == $util): ?><button class="btn btn-danger btn-sm rman"><span class="glyphicon glyphicon-trash"><?php endif; ?></td>
</tr>`;
}
In these two lines:
<td><?php if($colaborador == $util): ?><button type="button" data-target="#ad_man" class="btn btn-warning btn-sm edit_man" ><span class="glyphicon glyphicon-pencil"></span></button><?php endif; ?></td>
<td><?php if($colaborador == $util): ?><button class="btn btn-danger btn-sm rman"><span class="glyphicon glyphicon-trash"><?php endif; ?></td>
I intend to create the condition I have on those lines, but that way it doesn't work.
Can anyone help solve the problem?
$colabradorand$util?<td>${colaborador == util ? `<button ...>` : ''}</td>var util = $('#utl4').val();is the first line of javascript in the question. Andcolaborador = data[i][6];is inside the for in javascript