How to make joomla interact with an external php file to access the db

I’m trying to use joomla to get data from a database using an external php file.

The JOOMLA directory is: C:\xampp\htdocs\progetti\dilerooms

I create an Article: DASHBOARD and insert this code:

{source}

<script type="text/javascript">
var jQueryRepresentatives = jQuery.noConflict();
jQueryRepresentatives(document.body).on('change','#state',function(){ 

jQueryRepresentatives.ajax({


 type: 'GET',
 url: "http://localhost/progetti/dilerooms/index.php?option=com_ajax&module=k2_representatives&format=raw&Itemid=111&method=getRepresentatives&state="+jQueryRepresentatives('#state').val(),
  success:function(data){
   jQueryRepresentatives('#results').html(data);
  },
  error:function(){

   jQueryRepresentatives('#results').html('<p>error '+jQueryRepresentatives('#state').val()+'</p>');
  }
 }); 
});

</script>


<form action="" method="post"><strong>DETTAGLI SPESE CONTO</strong>
<select id="state">
<option value="NA">Seleziona anno</option>


<?php
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query = "SELECT idanno FROM #__anno";

$db->setQuery($query);
$results = $db->loadAssocList();

if($results != null){
foreach ( $results as $print ){
echo '<option>'.$print['idanno'].'</option>';
}
}
else
{
echo "Error table anno";
}
?>


</select>
</form>
<div id="results"> </div>{/source}

I create a mod_k2_representatives module:

{source}<?php

defined('_JEXEC') or die ;
require_once (dirname(dirname(__FILE__)).'/test.php');
$items = modK2RepresentativesHelper::getItems($params);

?>{/source}

and i create test.php in the joomla directory:

<?php
    class modK2RepresentativesHelper{
        
        function getItems(&$params, $format = ‘html’){
            
            "<strong>Ciao " . $params . "</strong>";
        }
        function getRepresentativesAjax(){
            "<strong>Ciao " . $params . "</strong>";    
        }
    }
?>

image

I expect that when I select the drop-down menu it will print what is inside the test.php file; but it goes in error:function().