Files
crm_php/.hta_slug/leads/_home copy 2.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'];
?>
<?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 business_verticals");
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (count($rows) >= 1) {
foreach($rows as $row){
echo ' <div style="display: flex; flex-direction: row;">
<a href="/cleads/by-business-verticals/?bv='.$row['bv'].'">'.$row['bv'].'</a>
</div>';
}
} else {
echo "<p class='text-danger'>Not Found any Data</p>";
}
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
}
?>
<div>
<?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 10");
foreach ($accessArray as $key => $value) {
$stmt->bindValue($key + 1, $value);
}
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
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>