ammesso che tu abbia installato DBI, che il tuo DB sia MySQL e che tu abbia installato DBD::MySQL

$nomeDB="NOME DB";#Nome Database
$host="HOST";#Nome Host Database
$utente="USER";#Nome user Database
$password="PASSWORD";#Password Database

use DBI();
$dbh = DBI->connect("DBI:mysql:database=$nomeDB;host=$host"," $utente","$password");

$sth = $dbh->prepare("SELECT * FROM dati WHERE CodStaz = '?'");

#? tra '' rappresenta il filtro di ricerca e CodStaz il campo di ricerca

$sth->execute();
while($ref=$sth->fetchrow_hashref())
{
#Questo ciclo mostra ogni singola riga
#Per leggere ciò che è scritto in un campo, riga per riga usa: $ref->{'NOMECAMPO'} qui dentro
}
$sth->finish();


alternativa:

$sth->$sth = $dbh->prepare("SELECT * FROM dati WHERE CodStaz = '?'");
$sth->execute();
while(@ref=$sth->fetchrow_array())
{
#Questo ciclo mostra ogni singola riga
#@ref è un array che contiene i tuoi dati
}
$sth->finish();

Spero di aver capito correttamente ciò che chiedevi