mardi 2 décembre 2014

Sql search combination


Vote count:

0




What's the best way to get the search result for a combination search of both 'f_nam'` and 'l_name'


At the moment, f_name and l_name when searched individually pulls up the search result. However, combining f_name and l_name in one search query brings up nothing. Mayber my operators are wrong?



$search = filter_input(INPUT_POST,'search',FILTER_CALLBACK,array('options'=>'alpha_num'));

$name = (@$_GET['fname'])?(($_GET['fname'] == 'asc')?('fname=desc'):('fname=asc')):('fname=asc');
$age = (@$_GET['age'])?(($_GET['age'] == 'asc')?('age=desc'):('age=asc')):('age=asc');
$iso = (@$_GET['iso'])?(($_GET['iso'] == 'asc')?('iso=desc'):('iso=asc')):('iso=asc');
$org = (@$_GET['org'])?(($_GET['org'] == 'asc')?('org=desc'):('org=asc')):('org=asc');
$csc = (@$_GET['csc'])?(($_GET['csc'] == 'asc')?('csc=desc'):('csc=asc')):('csc=asc');

if(!empty($search)) {
$results = $wpdb->get_results("SELECT * FROM `wp_plegde` WHERE `active` = '1' AND `delete` = '0' AND (`f_name` LIKE '%$search%' OR `l_name` LIKE '%$search%' OR `age` LIKE '%$search%' OR `i_shout` LIKE '%$search%' OR `org_name` LIKE '%$search%' OR `city` LIKE '%$search%' OR `state` LIKE '%$search%') ORDER BY f_name asc", ARRAY_A);
} else {
$results = $wpdb->get_results("SELECT * FROM `wp_plegde` WHERE `active` = '1' AND `delete` = '0' ".orderBy(), ARRAY_A);
}


asked 15 secs ago







Sql search combination

Aucun commentaire:

Enregistrer un commentaire