Hi Team
I need some help on jquery side and php, i have this search and want to create a js file that will be triggered when insert a search field from the products available from the database(php using query).
Code
// jquery side
---need help
// php side
--need help
Rajkiran SwainRank #165 · 14.4K reputationPosted May 6, 2023, 9:58 AM EDT
$(document).ready(function() { $('#searchField').on('keyup', function() { var searchText = $(this).val(); if(searchText.length >= 3) { // Perform search when search text is at least 3 characters long $.ajax({ url: 'search.php', method: 'POST', data: { searchText: searchText }, success: function(response) { $('#searchResults').html(response); } }); } else { $('#searchResults').html(''); } }); });query("SELECT * FROM products WHERE name LIKE '%{$searchText}%'"); // Display the search results // Example: // foreach($products as $product) { // echo ''.$product['name'].' '; // } } ?>Note: You will need to modify the PHP code according to your database schema and connection method.