There is a table with a list of customers. There are about 22 fields.
When displaying a list there are filters by them ... And one of the filters is a search field. Enter the text and look for.
Now I do it like this:
$search = mysql_real_escape_string($_POST['search']); if($search !=""){$query_text="AND (`org_name` LIKE '%$search%' OR `sfera` LIKE '%$search%' OR `d_fio` LIKE '%$search%' OR `d_phone` LIKE '%$search%' OR `d_email` LIKE '%$search%' OR `d_birth` LIKE '%$search%' OR `k_fio` LIKE '%$search%' OR `k_phone` LIKE '%$search%' OR `k_email` LIKE '%$search%' OR `k_dolzhnost` LIKE '%$search%' OR `k_birth` LIKE '%$search%' OR `inn` LIKE '%$search%' OR `kpp` LIKE '%$search%' OR `ogrn` LIKE '%$search%' OR `ur_adress` LIKE '%$search%' OR `rasch_schet` LIKE '%$search%' OR `bank_name` LIKE '%$search%' OR `bank_adress` LIKE '%$search%' OR `koresp_schet` LIKE '%$search%' OR `bik` LIKE '%$search%' OR `fax` LIKE '%$search%')";} mysql_query("SELECT * FROM clients WHERE id!='' $query_text");
But you yourself probably understand how it is not right (Maybe you can somehow optimize it?
concat_ws(',', org_name, sfera, d_fio, d_phone, d_email, d_birth, k_fio, ....) like '%$search%'
- instead of ellipsis, other fields. If the comma is found in the pattern, put another separator. - alexlz