使用“birth_day”,“birth_month”搜索术语

时间:2017-03-13 08:28:20

标签: php

我想在D.O.B中搜索这些字段“birth_day”,“birth_month”

function search_users($term, $limit = 10, $friends = false) {
$sql = "SELECT * FROM `users` WHERE
    (username LIKE '%{$term}%' OR first_name LIKE '%{$term}%' OR last_name LIKE '%{$term}%' OR email_address LIKE '%{$term}%') AND bannned='0'
 ";

1 个答案:

答案 0 :(得分:1)

$combined = $term;
$searchfield = explode(" ", $combined);
$sql = "SELECT * FROM `users` WHERE
    (username LIKE '%{$term}%' OR first_name LIKE '%{$term}%' OR last_name LIKE '%{$term}%' OR email_address LIKE '%{$term}%' OR birth_month LIKE '%{$term}%' OR birth_day LIKE '%{$searchfield[0]}%' ) AND bannned='0'
 ";