Create zip file from changing list of files

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 1
Joined: Wed Jan 22, 2020 3:28 am

Wed Jan 22, 2020 3:52 am

Please excuse the "newbie" nature of this question:
I have a search form which creates an sql string (inserting AND if value isn't null etc) and that sql string then allows display of rows from tables.
One of the columns is a reference to a separate datafile and each row in the table has an associated separate datafile.
The datarows response to "while ($rows = mysqli_fetch_assoc($result))" could be anything between 1 and 900 depending upon the factors chosen.

What I need is to be able to select each of the filename(s) given in the filename column and add each to the zipfile for that search.

I've done some sample testing, and if i explicitly name the file in the 'zip->addFile' instruction it works fine - a dozen consecutive statements gives a dozen files nicely zipped. But as explained, the explicit filename will only be known as a result of the sql search in a variable.

I've tried having the zip->addfile read the source name from an array:
and that fails.

I'd be grateful for any push in a direction that helps.
php-forum GURU
php-forum GURU
Posts: 653
Joined: Fri Apr 01, 2016 2:18 am

Wed Jan 22, 2020 6:30 am

So if you have a script that works, and the one that doesn't, look at the differences, here it must be the filename

Code: Select all

Post Reply