0

I want to generate reports in PHP txt.

But I don't get the desired result. I need you to show me only the header once. And he repeats it to me.

This is my code:

 $sqlPol = $conn->query("SELECT * FROM polizasap_enc a
                            RIGHT join polizasap_det b
                            on a.id_Rec = b.id_Rec");
$file = 'datos.txt';
$jump = "\r\n";
$separator = "  ";

$fp = fopen($file , 'w') or die("Unable to open file!");;

foreach ($sqlPol as $key => $row) {

    $registroCab = $row['tipoRegistro'] . $separator . $row['claseDoc'] . 
    $separator . $row['fechaDoc'] . $separator  . $row['fechaCont'].  
    $separator  . $row['referencia']. $separator . $row['texto']. $jump;

    $registroDet = $row['tpoRegistro'] . $separator . $row['ctaContable'] . 
    $separator . $row['importe'] . $separator  . $row['moneda']. $separator  
    . $row['posPre']. $separator . $row['txtPosicion']. $jump;

    fwrite($fp, $registroCab.$registroDet);
}
fclose($fp); 

what i get / what i need enter image description here

4

0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.