<?php

           $sq112ZaA1="SELECT * FROM $table_name80 WHERE survey_id = '$findsurv[$XQ1]' AND survey_id != '0' $Xextra Order by create_date ASC limit 1";      //Summing of Points
 $result33ZZA1 = @mysql_query($sq112ZaA1,$connection) or die(mysql_error());
while ($row122A1 = mysql_fetch_array($result33ZZA1)) {
$testbob1= $row122A1['create_date'];
          if (  $Fstarttime1[$j] ==''){
  $Fstarttime1[$j]=$testbob1;
                }   //end if
          $starttime1a=strtotime($Fstarttime1[$j]);
         $testbob1a=strtotime($testbob1);
           if  ($starttime1a<$testbob1a){
           $Fstarttime1[$j]=$Fstarttime1[$j];
               }else{
               $Fstarttime1[$j]=$testbob1;
               } //end else
                 }
                    $testbob1='';
           $sq112ZaA1="SELECT * FROM $table_name80 WHERE survey_id = '$findsurv[$XQ1]' AND survey_id != '0' $Xextra Order by create_date DESC limit 1";      //Summing of Points
 $result33ZZA1 = @mysql_query($sq112ZaA1,$connection) or die(mysql_error());
while ($row122A1 = mysql_fetch_array($result33ZZA1)) {
//$starttime2[$j]= $row122A1['create_date'];
$testbob1= $row122A1['create_date'];
          if (  $Fstarttime2[$j] ==''){
  $Fstarttime2[$j]=$testbob1;
                }   //end if
          $starttime1a=strtotime($Fstarttime2[$j]);
         $testbob1a=strtotime($testbob1);
           if  ($starttime1a>$testbob1a){
           $Fstarttime2[$j]=$Fstarttime2[$j];
               }else{
               $Fstarttime2[$j]=$testbob1;
               } //end else



                    }

    //      echo "$j -Fst -$Fstarttime1[$j]  end -$Fstarttime2[$j] <br/>";



         $sq112ZaA="SELECT * FROM $table_name80 WHERE survey_id = '$findsurv[$XQ1]' AND survey_id != '0' $Xextra ";      //Summing of Points
 $result33ZZA = @mysql_query($sq112ZaA,$connection) or die(mysql_error());
while ($row122A = mysql_fetch_array($result33ZZA)) {
$map_idZAA= $row122A['map_id'];


$sq112Za="SELECT * FROM $table_name79 WHERE map_id = '$map_idZAA' ";      //Summing of Points
$result33ZZ = @mysql_query($sq112Za,$connection) or die(mysql_error());
while ($row122 = mysql_fetch_array($result33ZZ)) {
//$survey_id122=  $row122['survey_id'];
              $X4bobv= stripslashes($row122["$findvan[$XQ1]"]);
               if ($X4bobv != $blink ){
   $X4bobv1[$j]="$X4bobv1[$j], $X4bobv ";
   if ($X4bobv1[$j]==", $X4bobv "){
     $X4bobv1[$j]=$X4bobv;
   }
   }

 //$vanZ[1]=stripslashes($row122['van1']);
 $X4vanZ1[$j]=$X4vanZ1[$j]+ stripslashes($row122["$findvan[$XQ1]"]);

 $X4ZZ1A[$j]=$X4ZZ1A[$j]+1;
  //       echo "vanz =$vanZ1 -leader_id1=$findkey[$sum1Q]-$findvan[$sum1Q]<br/>";

//echo "1Q - $findsurv[$sum1Q]- $map_idZAA<br />";

  }}     //Now lets get the sums

   //  echo "$XQ1=$X4bobv1[$j]<br/>";

?>
