I'm having a problem with a php script. The name attribute of a page receives a value that is generated by an array. What I need to do is basically generate a table in which each row has a button that serves to delete the same information received from the database, this button is which I use the attribute name to save the id of the received record. So, I do not know what I put on the other php page so that this value is saved. I'll put the code below for further analysis.
Below the php page that shows the elements on the screen.
<?php
$query = sprintf("SELECT conteudo, autor, titulo, pagina, id FROM atualizacoes ORDER BY id DESC");
$dados = mysql_query($query, $con) or die(mysql_error());
$linha = mysql_fetch_assoc($dados);
$total = mysql_num_rows($dados);
?>
<body>
<div class="row ">
<div class="col-md-8 col-md-offset-2">
<form name="login" method="post" action="../removendo.php">
<h2 style="color: white">Atualizando blog</h2>
<table class="tabelaconteudo">
<?php
if($total>0){
do{
?>
<tr>
'<td><?= $linha['titulo']?></td>
<td><?= $linha['pagina'] ?></td>
<td><?= $linha['autor'] ?></td>
<td><input type="submit" class="btn-cad" style="color: white" value="Apagar"
name="ref_<?= $linha['id'] ?>"></td> //AQUI É O CAMPO O QUAL NÃO CONSIGO SALVAR A INFORMAÇÃO
</tr>
<?php
}while ($linha = mysql_fetch_assoc($dados));
}
?>
</table>
</form>
</div>
</div>
</body>
Below the php page that loads when you press the submit button (the same as I can not set a specific name).
<?php
error_reporting (E_ALL & ~ E_NOTICE & ~ E_DEPRECATED);
$id=$_POST['NAME QUE NAO ESTA DEFINIDO'];
$restid = substr($id, 1, 4);
$sql = mysql_query("DELETE FROM atualizacoes WHERE id = $restid");
echo"
<script>
document.getElementById('loader').onpageshow = alertfunc();
function alertfunc() {
alert('Ocorreu algum erro.'$sql);
}
</script>
";
?>
I started with web programming a short time ago, and everything I've learned with php so far has been this. I've swept the entire internet behind this and never found something concrete so far, then in desperation I come here for help. From now on I thank all those who were willing to help.