i want to add checkboxes to each row in this table, the checkboxes are supposed to post that data and redirect user to delete.php, which will ask to delete or not. Here i have my admin user managment file:
<?php
session_start();
$username = $_SESSION['username'];
$loggedin = $_SESSION['loggedin'];
if ($username != "admin") {
header("location: 404.php"); exit;
} else {
include 'include/usermenu.php';
}
?>
<!DOCTYPE html>
<html>
<body>
<?php
echo "<table class='table' style='border: solid 1px black;'>";
echo "<tr><th>Id</th><th>Firstname</th><th>Lastname</th></tr>";
class TableRows extends RecursiveIteratorIterator {
function __construct($it) {
parent::__construct($it, self::LEAVES_ONLY);
}
function current() {
return "<td style='width: 150px; border: 1px solid black;'>" . parent::current(). "</td>";
}
function beginChildren() {
echo "<tr>";
}
function endChildren() {
echo "</tr>" . "\n";
}
}
$servername = "mysql.XXXXXXXXXX.co.uk";
$username = "XXXXXXXXX";
$password = "XXXXXXXX";
$dbname = "XXXXXXXXX";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT id_user, username, email FROM us3rs");
$stmt->execute();
// set the resulting array to associative
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) {
echo $v;
}
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
$conn = null;
echo "</table>";
?>
</body>
</html>
so how can i achieve that
Aucun commentaire:
Enregistrer un commentaire