1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
<?php
error_reporting(-1);
ini_set('display_errors', 'On');
$servername = "xxxx";
$username = "xxx";
$password = "xxx";
$dbname = "xxxx";
try {
$dbh = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
if(!empty($_GET["delete_id"])) {
$id = $_GET['delete_id'];
$sql = "DELETE FROM tagesroma WHERE id=:id";
$stmt = $dbh->prepare($sql);
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
$stmt->execute();
echo $stmt->rowCount() . " rows deleted<br>";
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Delete Record from table Tagesroma</title>
<script type="text/javascript">
function delete_id(id)
{
if(confirm('Sure To Remove This Record ?'))
{
window.location.href='delete.php?delete_id='+id;
}
}
</script>
</head>
<body>
<center>
<div id="header">
<div id="content">
<label>Delete Record from table Tagesroma</label>
</div>
</div>
<div id="body">
<div id="content">
<table align="center">
<?php
$stmt = $dbh->prepare("SELECT * FROM tagesroma");
$stmt->execute();
$data = $stmt->fetchAll();
if(count($data) > 0) {
foreach($data as $row) {
echo '<tr>';
echo "<td>" . $row['nome'] . "</td>";
echo "<td>" . $row['cognome'] . "</td>";
echo "<td>" . $row['indirizzo'] . "</td>";
echo "<td>" . $row['civico'] . "</td>";
echo "<td>" . $row['citta'] . "</td>";
echo "<td>" . $row['prov'] . "</td>";
echo "<a href='javascript:delete_id(" . $row["id"] . ")'>Delete this row</a>";
echo '</tr>';
}
} else {
echo "There's No data found !";
}
?>
</table>
</div>
</div>
</center>
<a title="Torna indietro" href="admin.php">Torna Indietro</a>
</body>
</html>