How to get the value using variable in AWK?

Hi All,
In below code, i am trying to read row line byb line to get the src & cod. Once i get the src & cod, i am trying to get the cnt from detail.txt file, where 1st column should match src & second column should match cod. But in both i am getting error. Could you please let me know where i have done a mistake?

 
cat main.txt | while read args
do
        src=`echo $args | awk -F"," '{print $1}'`
        cod=`echo $args | awk -F"," '{print $2}'`
 cnt=`awk -F"," '{ if ($1 == "$src" && $2 == "$cod") print $3}' detail.txt`
  or
 
 cnt=`awk -F"," '$1 ~ /$src/ && $2 ~ /$cod/ {print $3}' detail.txt`
 
done
 

what error are u getting? May be u shud try

cat main.txt | while read args
do
src=`echo $args | awk -F"," '{print $1}'`
cod=`echo $args | awk -F"," '{print $2}'`

cnt=`awk -F"," '$1 ~ /$src/ && $2 ~ /$cod/ {cnt1+=1}END{print cnt1}' detail.txt`
echo $cnt

done

cheers,
Devaraj Takhellambam

while IFS=, read src cod junk
do
   nawk -F, '$1==src && $2==cod {cnt++} END{print cnt}' src="${src}" cod="${cod}" detail.txt
done < main.txt