Files
crm_php/.hta_slug/users/_home copy.php
2024-05-01 18:13:22 +05:30

51 lines
2.2 KiB
PHP

<?php
require_once('.hta_config/crm_config.php');
require_once('.htac_header.php');
require_once('.htac_nav.php');
?>
<div>
<table style="overflow-x: auto;">
<thead>
<tr>
<th style="text-align: center;">Name</th>
<th style="text-align: center;">Email</th>
<th style="text-align: center;">Phone</th>
<th style="text-align: center;">Access</th>
<th style="text-align: center;">Time</th>
<th style="text-align: center;">Action</th>
</tr>
</thead>
<tbody>
<?php
try {
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT * FROM users");
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$num_rows = $stmt->rowCount();
if ($num_rows >= 1) {
foreach($rows as $row){
echo ' <tr>
<td style="text-align: center;">'.$row['name'].'</td>
<td style="text-align: center;">'.$row['email'].'</td>
<td style="text-align: center;">'.$row['mobile'].'</td>
<td style="text-align: center;">'.$row['access'].'</td>
<td style="text-align: center;">'.$row['time'].'</td>
<td style="text-align: center;"><a href="/users/edit-user/?id='.$row['id'].'">Edit</a> | <a href="/users/delete-user/?id='.$row['id'].'">Delete</a> </td>
</tr>';
}
} else{
echo "<p class='text-danger'>Not Found any Data</p>";
}
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
?>
</tbody>
</table>
</div>