I have this code to generate buttons on each table row with PHP and HTML:
<!DOCTYPE HTML>
<h2 class="text-center">Consulta</h2>
<br>
<table class="table table-striped">
<tr class="info">
<td class="black"><span style="font-weight:bold">#</span></td>
<td class="black"><span style="font-weight:bold">Data</span></td>
<td class="black"><span style="font-weight:bold">Condomínio</span></td>
<td class="black"><span style="font-weight:bold">Entrada</span></td>
<td class="black"><span style="font-weight:bold">Título</span></td>
<td class="black"><span style="font-weight:bold">Autor</span></td>
<td class="black"><span style="font-weight:bold">Estado</span></td>
<td class="black"><span style="font-weight:bold"></span></td>
</tr>
<?php
$select = "SELECT * FROM database";
$get = mysqli_query($cnn, $select) or die ('error');
while($row = mysqli_fetch_array($get, MYSQLI_ASSOC)) {
echo "<tr>";
echo "<td>";
echo $row['id'];
echo "</td><td>";
echo $row['data'];
echo "</td><td>";
echo $row['condominio'];
echo "</td><td>";
echo $row['entrada'];
echo "</td><td>";
echo $row['titulo'];
echo "</td><td>";
echo $row['autor'];
echo "</td><td>";
echo $row['estado'];
echo "</td><td>";
$html = '<form role="form" class="form-inline" method="POST" enctype="multipart/form-data" action="thispage.php">';
echo $html;
echo '<button type="submit" name="alter'.$row['id'].'" id="alter'.$row['id'].'" class="btn btn-default btn-xl">alter'.$row['id'].'</a></button>';
echo '</form>';
echo "</td>";
echo "</tr>";
}
echo "</table>";
?>
</html>
And, of course, I want to use the buttons, but the code below won't work for me:
<?php
$var = "row['id']";
$var2 = "alter".$var;
if (isset($_POST['$var2'])) {
echo('some code');
}
?>
I saw some solutions with Javascript but I can only use PHP and HTML, so if anyone could help I would appreciate it.