Categories > TinyButStrong general >

count after ondata deleting $CurrRec

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: TomH
Date: 2013-03-07
Time: 06:17

count after ondata deleting $CurrRec

I have an ondata function that sets the CurrRec = "" based on a calculation

Then I can use magnet to stop that record from displaying in the results block listing

But I need a count of the new number of rows remaining after some of the CurrRec rows are set to ""

Any ideas - I'm not seeing a way to do that

FYI, the ondata function being used...
function miles_calc_within($BlockName,&$CurrRec,$RecNum) {
    global $Db, $herelat, $herelon, $site_zip, $within;
    // test $CurrRec['miles'] = 123.4;
    $site_zip!="" ? $CurrRec['miles'] = sprintf("%.1f", calcDist($herelat, $herelon, $CurrRec['lat'], $CurrRec['lon']) ) : $CurrRec['miles'] =="";
    // can we kill this record altogether
        if($CurrRec['miles'] > $within){
            $CurrRec = "";
        }
    }

By: Sarah
Date: 2013-03-07
Time: 19:42

Re: count after ondata deleting $CurrRec

Can't you just add a counter variable? (This is not the best way but it will certainly work).

$numRecords = 0;
function miles_calc_within($BlockName,&$CurrRec,$RecNum) {
global $Db, $herelat, $herelon, $site_zip, $within, $numRecords;
// test $CurrRec['miles'] = 123.4;
$site_zip!="" ? $CurrRec['miles'] = sprintf("%.1f", calcDist($herelat, $herelon, $CurrRec['lat'], $CurrRec['lon']) ) : $CurrRec['miles'] =="";
// can we kill this record altogether
  if($CurrRec['miles'] > $within){
   $CurrRec = "";
  }else{
   $numRecords += 1;
  }
}