<?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 (  $Tstarttime1[$j] ==''){
  $Tstarttime1[$j]=$testbob1;
                }   //end if
          $starttime1a=strtotime($Tstarttime1[$j]);
         $testbob1a=strtotime($testbob1);
           if  ($starttime1a<$testbob1a){
           $Tstarttime1[$j]=$Tstarttime1[$j];
               }else{
               $Tstarttime1[$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 (  $Tstarttime2[$j] ==''){
  $Tstarttime2[$j]=$testbob1;
                }   //end if
          $starttime1a=strtotime($Tstarttime2[$j]);
         $testbob1a=strtotime($testbob1);
           if  ($starttime1a>$testbob1a){
           $Tstarttime2[$j]=$Tstarttime2[$j];
               }else{
               $Tstarttime2[$j]=$testbob1;
               } //end else



                    }

 //         echo "$j -Tst -$Tstarttime1[$j]  end -$Tstarttime2[$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'];
              $X3bobv= stripslashes($row122["$findvan[$XQ1]"]);
               if ($X3bobv != $blink ){
   $X3bobv1[$j]="$X3bobv1[$j], $X3bobv ";
   if ($X3bobv1[$j]==", $X3bobv "){
     $X3bobv1[$j]=$X3bobv;
   }
   }

 //$vanZ[1]=stripslashes($row122['van1']);
 $X3vanZ1[$j]=$X3vanZ1[$j]+ stripslashes($row122["$findvan[$XQ1]"]);

 $X3ZZ1A[$j]=$X3ZZ1A[$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 "TT-$XQ1=$X3bobv1[$j]<br/>";

?>
