2个不同的$ _POST方法,具有2个独立的数组条件

I have problem with 1 "&_POST[submit]" method, while other one is working fine.

I want to create 2 different $_POST methods for catching data from MongoDB and parse them into JSON in a way that one catches dates between $gte and $lte datapickers and the other one catches data for one particular date. This is the code:

<?php 
ini_set('mongo.long_as_object', 1); 
$dbhost = 'localhost';
$dbname = 'test';
$m = new MongoClient();
$db = $m->$dbname;
$results;
$rez;
$collection = $db->test; 
if(isset($_POST['submit'])){ 
$array = array( 
 'RasID' => $_POST['razberi'],
 'date' => array('$gte' => $_POST['datepickerOD'], '$lte' =>$_POST['datepickerDO'])
);
$results = $collection->find($array); 
}
elseif(isset($_POST['testic'])){
$array = array(
'date' => array($_POST['datepicker'])
);
$results = $collection->find($array);
}
else
{ 
$results = $collection->find()->limit(100);
} 
$rezic = array();
$series = array();
$i=0;
$br=0;
foreach($results as $result){ 
$series[$i]['Temperatura']=$result['Temperatura'];
$series[$i]['Insolacija']=$result['Insolacija'];
$series[$i]['date']=$result['date'];
$series[$i]['RasID']=$result['RasID'];
$i++;
}
foreach($results as $result){ 
$rezic[$br]['Temperatura']=$result['Temperatura'];
$rezic[$br]['Insolacija']=$result['Insolacija'];
$rezic[$br]['date']=$result['date'];
$rezic[$br]['RasID']=$result['RasID'];
$br++;
}
?>`

So with the $_POST['submit'] method I have no problem at all, it catches dates in a defined range, while the other one $_POST['testic'] can't pick me up all the files which contains that particular day, in fact it catches me all the data defined by the first form. Please help me out with this one. This is the JS code:

<script> 
$(function() { 
$( "#datepickerOD" ).datepicker({ dateFormat: 'yy-mm-dd' }); 
$( "#datepickerDO" ).datepicker({ dateFormat: 'yy-mm-dd' }); 
});
</script> 

<script> 
$(function() { 
$( "#datepicker" ).datepicker({ dateFormat: 'yy-mm-dd' }); 
});
</script> 

var chartData = <?php echo json_encode($series); ?> //this one is used for the first submit form

var fibra = <?php echo json_encode($rezic); ?> //this one is used for the second submit form `$_POST['testic']`.

How can I separate these arrays and apply them in these 2 var's? Thank you.