Skip to content
Advertisement

Upload txt file using PHP into database and then return Excel file

What I need to do is upload txt file into databe using PHP, do some calculations based on that table, and then return result in Excel file.

This code works well, but I’m not getting all data from the .txt file, since it looks like it stops when it finds a comma.

Here is the code:

JavaScript

And here is the content of the .txt file that has to be uploaded to the table visa_tc

JavaScript

The output that I get for this column ‘sequence[77,146]’ from the sql query is based on example of this entry:

10004083524334965010 06150000000000000000000000000014208978000000017180840VGBP BILLING FOR MAY 2021, INV 210500-13239- 0006, 421357 0611166479225089 11660

What I should get is:

VGBP BILLING FOR MAY 2021, INV 210500-13239- 0006, 421357

But what I ged is:

VGBP BILLING FOR MAY 2021

It looks like the sequence stops when it finds comma.

I tried this remedies in the code (with preg_replace)

JavaScript

Now I hope my question is more straightforward.

Thank you.

Advertisement

Answer

I was able to workout a solution:

JavaScript

So basically, only difference compared to the original code was that I added this:

JavaScript

Doesn’t seem like a fairly large reqirement to me.

Thank you!

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement