There is such an interesting question, I want to do that would be unloaded from the database (PostgreSQL) to the site and for this information I have already conducted a search.
Here is what I already have (index.php) (added lines that are formed with the base, for example, for now 2):
<!doctype html> <html lang="ru"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="assets/js/main.js"></script> <link rel="stylesheet" href="assets/css/style.css"> <title>Test</title> </head> <body> <table> <thead> <tr> <td><input id="search" type="text" placeholder="search" autofocus> </td> </tr> </thead> <tbody id="task"> <tr class="info-clients" style="display: table-row;"> <td class="id">1</td> <td class="company">Protect</td> <td class="country">Ukraine</td> <td class="good">Beer</td> </tr> <tr class="info-clients" style="display: table-row;"> <td class="id">2</td> <td class="company">Protect</td> <td class="country">Chaina</td> <td class="good">Gear</td> </tr> <script> clients(); </script> </tbody> </table> </body> </html> Next, my main.js:
function clients() { $.ajax({ type: 'GET', url: "../../clients.php", cache: false, success: function (clients) { $('#task').html(clients); } }); } jQuery(document).ready(function () { jQuery('#search').on('change click keyup', function () { var value = jQuery(this).val(); var comp = jQuery('.company').val(); var count = jQuery('.country').val(); var good = jQuery('.good').val(); if ((comp || count || good) != value) { jQuery('.info-clients').css('display', 'none'); } else { jQuery('.info-clients').css('display', 'table-row'); } }) }); And here I cant start, the logic here is such that when adding any text to input, it should immediately go through the logic and show only those lines that have these values, but when I’m empty, everything is shown but I just start to enter any word at once everything disappears as if no match was found, help my head for 3 days. I'm breaking what's wrong ((
In order to understand what is in clients.php:
<?php $conn = mysqli_connect('127.0.0.1','mysql', 'mysql', 'tryself', '3306'); if (!$conn) { exit ('MySQL error'); } $users = mysqli_query($conn, 'SELECT * FROM clients WHERE 1'); while ($row=mysqli_fetch_array($users)) { print "<tr class='info-clients'><td class='id-company'>".$row['id']."</td><td class='email-company'>".$row['email']."</td><td class='company-company'>".$row['company']."</td><td class='country-company'>".$row['country']."</td><td class='good-company'>".$row['good']."</td></tr>"; } ?>