<?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 = @mysqli_query($connection,$sq112ZaA1) or die(mysqli_error($connection));
while ($row122A1 = mysqli_fetch_array($result33ZZA1)) {
$testbob1= $row122A1['create_date'];
          if (  $Sstarttime1[$j] ==''){
  $Sstarttime1[$j]=$testbob1;
                }   //end if
          $starttime1a=strtotime($Sstarttime1[$j]);
         $testbob1a=strtotime($testbob1);
           if  ($starttime1a<$testbob1a){
           $Sstarttime1[$j]=$Sstarttime1[$j];
               }else{
               $Sstarttime1[$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 = @mysqli_query($connection,$sq112ZaA1) or die(mysqli_error($connection));
while ($row122A1 = mysqli_fetch_array($result33ZZA1)) {
//$starttime2[$j]= $row122A1['create_date'];
$testbob1= $row122A1['create_date'];
          if (  $Sstarttime2[$j] ==''){
  $Sstarttime2[$j]=$testbob1;
                }   //end if
          $starttime1a=strtotime($Sstarttime2[$j]);
         $testbob1a=strtotime($testbob1);
           if  ($starttime1a>$testbob1a){
           $Sstarttime2[$j]=$Sstarttime2[$j];
               }else{
               $Sstarttime2[$j]=$testbob1;
               } //end else



                    }

 //         echo "$j -Sst -$Sstarttime1[$j]  end -$Sstarttime2[$j] <br/>";



         $sq112ZaA="SELECT * FROM $table_name80 WHERE survey_id = '$findsurv[$XQ1]' AND survey_id != '0' $Xextra ";      //Summing of Points
 $result33ZZA = @mysqli_query($connection,$sq112ZaA) or die(mysqli_error($connection));
while ($row122A = mysqli_fetch_array($result33ZZA)) {
$map_idZAA= $row122A['map_id'];


$sq112Za="SELECT * FROM $table_name79 WHERE map_id = '$map_idZAA' ";      //Summing of Points
$result33ZZ = @mysqli_query($connection,$sq112Za) or die(mysqli_error($connection));
while ($row122 = mysqli_fetch_array($result33ZZ)) {
//$survey_id122=  $row122['survey_id'];
              $Xbobv= stripslashes($row122["$findvan[$XQ1]"]);
               if ($Xbobv != $blink ){
   $Xbobv1[$j]="$Xbobv1[$j], $Xbobv ";
   if ($Xbobv1[$j]==", $Xbobv "){
     $Xbobv1[$j]=$Xbobv;
   }
   }

 //$vanZ[1]=stripslashes($row122['van1']);
 $XvanZ1[$j]=$XvanZ1[$j]+ stripslashes($row122["$findvan[$XQ1]"]);

 $XZZ1A[$j]=$XZZ1A[$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=$Xbobv1[$j]<br/>";

?>
