Since you are only pulling a single record, you will never see more than one. For starters, you will have to set that number higher.
You will also need to pull in the fields "DateSet" and "DateExpires" to get the additional criteria.
You will have to loop through the resulting array in PHP and select the record which meets your internal requirements.
** Can't post the full code, forum needs fixin' **
| Code: : |
$app = new iSDK;
$app->cfgCon("InfusionSoftApp");
$cid=(int)$cid ;
$returnF = array('AffiliateId','DateSet',DateExpires');
$query = array('ContactId' => $cid);
IF ($referrals = $app->dsQuery("Referral",1000,0,$query,$returnF)) :
$query_ok = TRUE;
ELSE :
$query_ok = FALSE;
ENDIF;
$refid = false;
$newest = '';
IF ($query_ok) :
FOREACH ($referrals as $k => $referral) :
IF ($referral['DateExpires]
|