This commit is contained in:
Suvodip
2024-05-08 23:29:29 +05:30
parent 1ba7ea57eb
commit 7af59fdbdd
4 changed files with 94 additions and 9 deletions

View File

@@ -219,11 +219,13 @@
$placeholderString = implode(',', array_fill(0, count($accessArray), '?'));
//first query to get the total number for pagination
$parts = explode(',', $_SESSION["states"]);
$states=$_SESSION["states"];
if( strlen($_SESSION["states"]) <2 ) $states='no_states_access_selected';
$parts = explode(',', $states);
$quotedParts = array_map(function($item) { return "'" . $item . "'";}, $parts);
$newStr = implode(',', $quotedParts);
$stateAcc = implode(',', $quotedParts);
$sql= "SELECT COUNT(*) FROM cleads WHERE state IN ($newStr) OR user LIKE :user AND business_type LIKE :businessVertical AND (name LIKE :searchTerm OR phone LIKE :searchTerm OR id LIKE :searchTerm OR email LIKE :searchTerm ) AND time BETWEEN :start_date AND :end_date ";
$sql= "SELECT COUNT(*) FROM cleads WHERE state IN ($stateAcc) OR user LIKE :user AND business_type LIKE :businessVertical AND (name LIKE :searchTerm OR phone LIKE :searchTerm OR id LIKE :searchTerm OR email LIKE :searchTerm ) AND time BETWEEN :start_date AND :end_date ";
$stmt = $conn->prepare($sql);
$stmt->bindValue(':businessVertical', $businessVertical);
$stmt->bindValue(':searchTerm', "%".$searchTerm."%");
@@ -235,7 +237,7 @@
// second & final query to get the page_view data
$sql = "SELECT * FROM cleads WHERE state IN ($newStr) OR user LIKE :user AND business_type LIKE :businessVertical AND (name LIKE :searchTerm OR phone LIKE :searchTerm OR id LIKE :searchTerm OR email LIKE :searchTerm ) AND time BETWEEN :start_date AND :end_date ORDER BY id DESC LIMIT :limit OFFSET :offset";
$sql = "SELECT * FROM cleads WHERE state IN ($stateAcc) OR user LIKE :user AND business_type LIKE :businessVertical AND (name LIKE :searchTerm OR phone LIKE :searchTerm OR id LIKE :searchTerm OR email LIKE :searchTerm ) AND time BETWEEN :start_date AND :end_date ORDER BY id DESC LIMIT :limit OFFSET :offset";
$stmt = $conn->prepare($sql);
$stmt->bindValue(':businessVertical', $businessVertical, PDO::PARAM_STR );
$stmt->bindValue(':searchTerm', "%$searchTerm%"); // PDO::PARAM_STR is the default data type binding so is not needed