Hello, I am doing a table filter here at ktg.megusto.kz , and I need to somehow arrange the filter correctly, I have already tried everything and found nothing, now the code is
require_once "core/db_config.php"; if (isset($_GET['submit'])) { $fields = array('order_user', 'method', 'data_from', 'data_to'); $conditions = array(); foreach ($fields as $field) { if (isset($_GET[$field]) && $_GET[$field] != '') { $conditions[] = "`$field` LIKE '%" . $_GET[$field] . "%'"; } } $sql = "SELECT * FROM `ktg_base`"; if (count($conditions) > 0) { $sql .= "WHERE " . implode(' AND ', $conditions); } } else { $sql = "SELECT * FROM `ktg_base` WHERE del = 0"; } $result = $mysqli->query($sql) or die(mysqli_error($sql)); while ($row = mysqli_fetch_assoc($result)) { echo '<tr data-id="' . $row['id'] . '">'; echo '<td>' . $row['id'] . '</td>'; echo '<td>' . $row['order_user'] . '</td>'; echo '<td>' . $row['organizator'] . '</td>'; echo '<td>' . $row['name'] . '</td>'; echo '<td>' . $row['method'] . '</td>'; echo '<td>' . $row['data_from'] . '</td>'; echo '<td>' . $row['data_to'] . '</td>'; echo '<td>' . $row['status'] . '</td>'; echo '</tr>'; } How everything should work, but it’s somehow not clear how to do it right? There are all 3 villages, and one field for searching the entire table.