Prova così:
Codice PHP:
<script type="text/javascript">
// Confirm submission of delete form
function verify() {
msg = "Sicuro di voler cancellare?";
return confirm(msg);
}
</script>
<table border="1" width="100%" style="border-collapse: collapse" id="table1">
<form name="myform" action="delete.php" method="POST">
<?php
include("config.inc.php");
$db = mysql_connect($host, $username);
if ($db == FALSE)
die ("Errore nella connessione. Verificare i parametri.");
mysql_select_db($database, $db)
or die ("Errore nella selezione del database. Verificare i parametri.");
$query = "SELECT * FROM calcetto_nextmatch ORDER BY data";
$result = mysql_query ($query, $db);
$i = 0;
while ($line = mysql_fetch_array ($result))
{
$i++;
echo '<tr>';
echo '<td width="20%">' . $line['data'] . '</td>';
echo '<td width="20%">' . $line['orario'] . '</td>';
echo '<td width="20%">' . $line['competizione'] . '</td>';
echo '<td width="20%">' . $line['avversario'] . '</td>';
echo '<td width="20%">Elimina <input type="radio" name="delet" value="'.$line['id'].'" /></td>';
echo '</tr>';
}
mysql_close($db);
?>
<tr><td colspan="5" align="center">
<input type="submit" value="Delete" onclick="return verify()">
</td></tr>
</form>
</table>
la pagina delete.php è così:
Codice PHP:
<?php
...
...
...
$name_inp = (!empty($_POST['delet'])) ? trim($_POST['delet']) : '';
$name = addslashes($name_inp);
if($name != null && $name != ''){
$result = mysql_query("DELETE FROM calcetto_nextmatch WHERE id='$name'") or die("Could not delete record");
echo("The record has been deleted");
// Then redirect them somewhere useful
}
...
...
...
?>