EVOLUTION-NINJA
Edit File: list.php
//list.php <section class="home-section"> <div class="home-content"> <i class='bx bx-menu'></i> </div> <div class="container mt-4"> <h2>Product List</h2> <!-- 🔍 Search Box --> <input type="text" id="searchBox" class="form-control" placeholder="Search Model..."> <br> <!-- 📊 Table --> <table class="table table-bordered" id="productTable"> <thead> <tr> <th>Sl No</th> <th>Model</th> <th>RC Price</th> <th>Basic Price</th> <th>NDP</th> <th>GST%</th> <th>Action</th> </tr> </thead> <tbody></tbody> </table> </div> </section> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js"></script> <link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css"> <script> $(document).ready(function(){ // 🔹 Load all products initially fetchProducts(); function fetchProducts(search = '') { $.ajax({ url: "<?= base_url('products/get') ?>", type: "GET", data: { search: search }, success: function(data){ let html = ''; if (data.length === 0) { html = `<tr><td colspan="8" class="text-center">No data found</td></tr>`; } data.forEach(function(p, index){ html += ` <tr> <td>${index + 1}</td> <td>${p.model_name}</td> <td>${p.rc_price}</td> <td>${p.basic_price}</td> <td>${p.ndp}</td> <td>${p.gst_percent}</td> <td> <button class="btn btn-sm btn-primary">Edit</button> <button class="btn btn-sm btn-danger">Delete</button> </td> </tr>`; }); $('#productTable tbody').html(html); } }); } // 🔍 Auto Suggestion $("#searchBox").autocomplete({ source: function(request, response) { $.ajax({ url: "<?= base_url('products/search') ?>", type: "GET", data: { term: request.term }, success: function(data) { response(data); } }); }, select: function(event, ui) { fetchProducts(ui.item.value); } }); // 🔎 Live typing search $('#searchBox').keyup(function(){ let value = $(this).val(); fetchProducts(value); }); }); </script> <?php echo view('includes/footer'); ?>