Files
crm_php/.hta_slug/leads/v3.php
2024-05-03 21:08:57 +05:30

68 lines
2.8 KiB
PHP

<?php
require_once('.hta_config/crm_config.php');
require_once('.htac_header.php');
require_once('.htac_nav.php');
// echo $_SESSION['access'];
?>
<div>
<table style="overflow-x: auto;" id="myTable">
<thead>
<tr>
<th style="text-align: center;">Name</th>
<th style="text-align: center;">ID</th>
<th style="text-align: center;">Status</th>
<th style="text-align: center;">Email</th>
<th style="text-align: center;">Phone</th>
<th style="text-align: center;">business_type</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);
$accessArray = explode(",", $_SESSION['access']);
$placeholders = rtrim(str_repeat('?,', count($accessArray)), ','); // Creating placeholders like ?,?,?,?
$stmt = $conn->prepare("SELECT * FROM cleads WHERE business_type IN ($placeholders) LIMIT 2");
foreach ($accessArray as $key => $value) {
$stmt->bindValue($key + 1, $value);
}
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
// var_dump($rows);
echo json_encode($rows);
echo '
<div id="example-table"></div>
<link href="https://unpkg.com/tabulator-tables@6.2.0/dist/css/tabulator.min.css" rel="stylesheet">
<script type="text/javascript" src="https://unpkg.com/tabulator-tables@6.2.0/dist/js/tabulator.min.js"></script>
<script>
//define data
var tabledata = '.json_encode($rows).';
//define table
var table = new Tabulator("#example-table", {
data:tabledata,
autoColumns:true,
});
</script>
';
$num_rows = $stmt->rowCount();
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
?>
</tbody>
</table>
</div>
<!-- <script src="https://cdn.datatables.net/2.0.3/js/dataTables.js"></script>
<script>
let table = new DataTable('#myTable', {
// options
});
</script> -->