我写搜索查询以显示婚姻配置文件。但它不显示任何结果。在此查询中,我在PHPMyAdmin中运行其显示10个结果。
请建议任何解决此错误的好方法。
我的代码在
下面 if(!empty($items['search_profile_id'])){ //user first name
$strCond = " and truematrimony_profile_id = '".$items['search_profile_id']."'";
}
if(!empty($items['gender'])){
$strCond .= (!empty($strCond)) ? " and (gender = '".$items['gender']."')" : " and (gender = '".$items['gender']."')" ;
}
if(!empty($items['caste'])){
$strCond .= (!empty($strCond)) ? " and (caste_id != '".$items['caste']."')" : " and (caste_id != '".$items['caste']."')";
}
if(!empty($items['education'])){
$strCond .= (!empty($strCond)) ? " and (highesteducation_id = '".$items['education']."')" : " and (highesteducation_id = '".$items['education']."')";
}
if(!empty($items['occupation'])){
$strCond .= (!empty($strCond)) ? " and (occupation_id = '".$items['occupation']."')" : " and (occupation_id = '".$items['occupation']."')";
}
if(!empty($items['complexion'])){
$strCond .= (!empty($strCond)) ? " and (complexion_id = '".$items['complexion']."')" : " and (complexion_id = '".$items['complexion']."')";
}
// echo $strCond;
//exit;
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query = "SELECT * FROM #__truematrimony_profiles WHERE truematrimony_profile_id != '0' $strCond order by truematrimony_profile_id DESC LIMIT 10;";
$db->setQuery($query);
$db->execute();
//$query->select('*');
//$query->from('#__truematrimony_profiles');
//$query->where('truematrimony_profile_id != 0'.$strCond);
//$query->order('truematrimony_profile_id DESC');
//$query->setLimit(15);
//$db->setQuery($query);
$profileinfo = $db->loadAssocList();