php - Search content using date function -
by using function have search content in database date. coding works enough well. dont explode it. possible search record date using strtotome() rather explode??
function doselectbranchrecords($objarray) { $strwhereclause = ''; if ($objarray['frmnamesearch']) { $strwhereclause.= " , a.branch_ident = '".$objarray['frmnamesearch']."' "; } if ($objarray['frmloansearch']) { $strwhereclause.= " , a.loan_ident '%".$objarray['frmloansearch']."%' "; } if ($objarray['frmbeneficiarysearch']) { $strwhereclause.= " , a.beneficiary_idents '%".$objarray['frmbeneficiarysearch']."%' "; } if ($objarray['frmdatesearch']) { $strdate = explode("-", $objarray['frmdatesearch']); $straccountstarted = $strdate[2].'-'.$strdate[1].'-'.$strdate[0]; $strwhereclause.= " , a.account_started = '".$straccountstarted."' "; } $strsqlselect = "select a.*, b.branch_name tbl_companydetails a,tbl_branchdetails b a.branch_ident = b.branch_id $strwhereclause order company_id desc"; $strvalues = selectqry($strsqlselect); return $strvalues; }
try replace
$strdate = explode("-", $objarray['frmdatesearch']); $straccountstarted = $strdate[2].'-'.$strdate[1].'-'.$strdate[0];
with
$straccountstarted = date('y-m-d h:i:s', strtotime($objarray['frmdatesearch']));
if don't need time remove h:i:s
date.
Comments
Post a Comment